Lines Matching refs:context
438 bool validate(OperationType opType, const IOperationValidationContext* context) { in validate() argument
442 NN_RET_CHECK_EQ(context->getNumInputs(), kNumInputs); in validate()
443 NN_RET_CHECK_EQ(context->getNumOutputs(), kNumOutputs); in validate()
444 auto inputType = context->getInputType(kInputTensor1); in validate()
446 NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_0, opIntroducedAt))); in validate()
448 NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_2, opIntroducedAt))); in validate()
451 NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_2, opIntroducedAt))); in validate()
455 Shape output = context->getOutputShape(kOutputTensor); in validate()
456 Shape input1 = context->getInputShape(kInputTensor1); in validate()
457 Shape input2 = context->getInputShape(kInputTensor2); in validate()
459 NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_0, opIntroducedAt))); in validate()
461 NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_0, opIntroducedAt))); in validate()
465 NN_RET_CHECK(validateHalVersion(context, std::max(HalVersion::V1_3, opIntroducedAt))); in validate()
469 const Shape& input1 = context->getInputShape(kInputTensor1); in validate()
470 const Shape& input2 = context->getInputShape(kInputTensor2); in validate()
475 return validateInputTypes(context, {inputType, inputType, OperandType::INT32}) && in validate()
476 validateOutputTypes(context, {inputType}); in validate()
479 bool prepare(IOperationExecutionContext* context) { in prepare() argument
480 Shape input1 = context->getInputShape(kInputTensor1); in prepare()
481 Shape input2 = context->getInputShape(kInputTensor2); in prepare()
482 Shape output = context->getOutputShape(kOutputTensor); in prepare()
486 return context->setOutputShape(kOutputTensor, output); in prepare()
489 bool executeAdd(IOperationExecutionContext* context) { in executeAdd() argument
491 if (getNumberOfElements(context->getOutputShape(kOutputTensor)) == 0) return true; in executeAdd()
492 switch (context->getInputType(kInputTensor1)) { in executeAdd()
494 return addFloat16(context->getInputBuffer<_Float16>(kInputTensor1), in executeAdd()
495 context->getInputShape(kInputTensor1), in executeAdd()
496 context->getInputBuffer<_Float16>(kInputTensor2), in executeAdd()
497 context->getInputShape(kInputTensor2), in executeAdd()
498 context->getInputValue<int32_t>(kActivationScalar), in executeAdd()
499 context->getOutputBuffer<_Float16>(kOutputTensor), in executeAdd()
500 context->getOutputShape(kOutputTensor)); in executeAdd()
502 return addFloat32(context->getInputBuffer<float>(kInputTensor1), in executeAdd()
503 context->getInputShape(kInputTensor1), in executeAdd()
504 context->getInputBuffer<float>(kInputTensor2), in executeAdd()
505 context->getInputShape(kInputTensor2), in executeAdd()
506 context->getInputValue<int32_t>(kActivationScalar), in executeAdd()
507 context->getOutputBuffer<float>(kOutputTensor), in executeAdd()
508 context->getOutputShape(kOutputTensor)); in executeAdd()
510 return addQuant8(context->getInputBuffer<uint8_t>(kInputTensor1), in executeAdd()
511 context->getInputShape(kInputTensor1), in executeAdd()
512 context->getInputBuffer<uint8_t>(kInputTensor2), in executeAdd()
513 context->getInputShape(kInputTensor2), in executeAdd()
514 context->getInputValue<int32_t>(kActivationScalar), in executeAdd()
515 context->getOutputBuffer<uint8_t>(kOutputTensor), in executeAdd()
516 context->getOutputShape(kOutputTensor)); in executeAdd()
518 return addQuant8(context->getInputBuffer<int8_t>(kInputTensor1), in executeAdd()
519 context->getInputShape(kInputTensor1), in executeAdd()
520 context->getInputBuffer<int8_t>(kInputTensor2), in executeAdd()
521 context->getInputShape(kInputTensor2), in executeAdd()
522 context->getInputValue<int32_t>(kActivationScalar), in executeAdd()
523 context->getOutputBuffer<int8_t>(kOutputTensor), in executeAdd()
524 context->getOutputShape(kOutputTensor)); in executeAdd()
526 return executeInt32(context->getInputBuffer<int32_t>(kInputTensor1), in executeAdd()
527 context->getInputShape(kInputTensor1), in executeAdd()
528 context->getInputBuffer<int32_t>(kInputTensor2), in executeAdd()
529 context->getInputShape(kInputTensor2), in executeAdd()
530 context->getInputValue<int32_t>(kActivationScalar), in executeAdd()
531 context->getOutputBuffer<int32_t>(kOutputTensor), in executeAdd()
532 context->getOutputShape(kOutputTensor), in executeAdd()
539 bool executeMul(IOperationExecutionContext* context) { in executeMul() argument
541 if (getNumberOfElements(context->getOutputShape(kOutputTensor)) == 0) return true; in executeMul()
542 switch (context->getInputType(kInputTensor1)) { in executeMul()
544 return mulFloat16(context->getInputBuffer<_Float16>(kInputTensor1), in executeMul()
545 context->getInputShape(kInputTensor1), in executeMul()
546 context->getInputBuffer<_Float16>(kInputTensor2), in executeMul()
547 context->getInputShape(kInputTensor2), in executeMul()
548 context->getInputValue<int32_t>(kActivationScalar), in executeMul()
549 context->getOutputBuffer<_Float16>(kOutputTensor), in executeMul()
550 context->getOutputShape(kOutputTensor)); in executeMul()
552 return mulFloat32(context->getInputBuffer<float>(kInputTensor1), in executeMul()
553 context->getInputShape(kInputTensor1), in executeMul()
554 context->getInputBuffer<float>(kInputTensor2), in executeMul()
555 context->getInputShape(kInputTensor2), in executeMul()
556 context->getInputValue<int32_t>(kActivationScalar), in executeMul()
557 context->getOutputBuffer<float>(kOutputTensor), in executeMul()
558 context->getOutputShape(kOutputTensor)); in executeMul()
560 return mulQuant8(context->getInputBuffer<uint8_t>(kInputTensor1), in executeMul()
561 context->getInputShape(kInputTensor1), in executeMul()
562 context->getInputBuffer<uint8_t>(kInputTensor2), in executeMul()
563 context->getInputShape(kInputTensor2), in executeMul()
564 context->getInputValue<int32_t>(kActivationScalar), in executeMul()
565 context->getOutputBuffer<uint8_t>(kOutputTensor), in executeMul()
566 context->getOutputShape(kOutputTensor)); in executeMul()
568 return mulQuant8(context->getInputBuffer<int8_t>(kInputTensor1), in executeMul()
569 context->getInputShape(kInputTensor1), in executeMul()
570 context->getInputBuffer<int8_t>(kInputTensor2), in executeMul()
571 context->getInputShape(kInputTensor2), in executeMul()
572 context->getInputValue<int32_t>(kActivationScalar), in executeMul()
573 context->getOutputBuffer<int8_t>(kOutputTensor), in executeMul()
574 context->getOutputShape(kOutputTensor)); in executeMul()
576 return executeInt32(context->getInputBuffer<int32_t>(kInputTensor1), in executeMul()
577 context->getInputShape(kInputTensor1), in executeMul()
578 context->getInputBuffer<int32_t>(kInputTensor2), in executeMul()
579 context->getInputShape(kInputTensor2), in executeMul()
580 context->getInputValue<int32_t>(kActivationScalar), in executeMul()
581 context->getOutputBuffer<int32_t>(kOutputTensor), in executeMul()
582 context->getOutputShape(kOutputTensor), in executeMul()
589 bool executeSub(IOperationExecutionContext* context) { in executeSub() argument
591 if (getNumberOfElements(context->getOutputShape(kOutputTensor)) == 0) return true; in executeSub()
592 switch (context->getInputType(kInputTensor1)) { in executeSub()
594 return subFloat16(context->getInputBuffer<_Float16>(kInputTensor1), in executeSub()
595 context->getInputShape(kInputTensor1), in executeSub()
596 context->getInputBuffer<_Float16>(kInputTensor2), in executeSub()
597 context->getInputShape(kInputTensor2), in executeSub()
598 context->getInputValue<int32_t>(kActivationScalar), in executeSub()
599 context->getOutputBuffer<_Float16>(kOutputTensor), in executeSub()
600 context->getOutputShape(kOutputTensor)); in executeSub()
602 return subFloat32(context->getInputBuffer<float>(kInputTensor1), in executeSub()
603 context->getInputShape(kInputTensor1), in executeSub()
604 context->getInputBuffer<float>(kInputTensor2), in executeSub()
605 context->getInputShape(kInputTensor2), in executeSub()
606 context->getInputValue<int32_t>(kActivationScalar), in executeSub()
607 context->getOutputBuffer<float>(kOutputTensor), in executeSub()
608 context->getOutputShape(kOutputTensor)); in executeSub()
610 return subQuant8(context->getInputBuffer<uint8_t>(kInputTensor1), in executeSub()
611 context->getInputShape(kInputTensor1), in executeSub()
612 context->getInputBuffer<uint8_t>(kInputTensor2), in executeSub()
613 context->getInputShape(kInputTensor2), in executeSub()
614 context->getInputValue<int32_t>(kActivationScalar), in executeSub()
615 context->getOutputBuffer<uint8_t>(kOutputTensor), in executeSub()
616 context->getOutputShape(kOutputTensor)); in executeSub()
618 return subQuant8(context->getInputBuffer<int8_t>(kInputTensor1), in executeSub()
619 context->getInputShape(kInputTensor1), in executeSub()
620 context->getInputBuffer<int8_t>(kInputTensor2), in executeSub()
621 context->getInputShape(kInputTensor2), in executeSub()
622 context->getInputValue<int32_t>(kActivationScalar), in executeSub()
623 context->getOutputBuffer<int8_t>(kOutputTensor), in executeSub()
624 context->getOutputShape(kOutputTensor)); in executeSub()
626 return executeInt32(context->getInputBuffer<int32_t>(kInputTensor1), in executeSub()
627 context->getInputShape(kInputTensor1), in executeSub()
628 context->getInputBuffer<int32_t>(kInputTensor2), in executeSub()
629 context->getInputShape(kInputTensor2), in executeSub()
630 context->getInputValue<int32_t>(kActivationScalar), in executeSub()
631 context->getOutputBuffer<int32_t>(kOutputTensor), in executeSub()
632 context->getOutputShape(kOutputTensor), in executeSub()
639 bool executeDiv(IOperationExecutionContext* context) { in executeDiv() argument
641 if (getNumberOfElements(context->getOutputShape(kOutputTensor)) == 0) return true; in executeDiv()
642 switch (context->getInputType(kInputTensor1)) { in executeDiv()
644 return divFloat16(context->getInputBuffer<_Float16>(kInputTensor1), in executeDiv()
645 context->getInputShape(kInputTensor1), in executeDiv()
646 context->getInputBuffer<_Float16>(kInputTensor2), in executeDiv()
647 context->getInputShape(kInputTensor2), in executeDiv()
648 context->getInputValue<int32_t>(kActivationScalar), in executeDiv()
649 context->getOutputBuffer<_Float16>(kOutputTensor), in executeDiv()
650 context->getOutputShape(kOutputTensor)); in executeDiv()
652 return divFloat32(context->getInputBuffer<float>(kInputTensor1), in executeDiv()
653 context->getInputShape(kInputTensor1), in executeDiv()
654 context->getInputBuffer<float>(kInputTensor2), in executeDiv()
655 context->getInputShape(kInputTensor2), in executeDiv()
656 context->getInputValue<int32_t>(kActivationScalar), in executeDiv()
657 context->getOutputBuffer<float>(kOutputTensor), in executeDiv()
658 context->getOutputShape(kOutputTensor)); in executeDiv()
660 return executeInt32(context->getInputBuffer<int32_t>(kInputTensor1), in executeDiv()
661 context->getInputShape(kInputTensor1), in executeDiv()
662 context->getInputBuffer<int32_t>(kInputTensor2), in executeDiv()
663 context->getInputShape(kInputTensor2), in executeDiv()
664 context->getInputValue<int32_t>(kActivationScalar), in executeDiv()
665 context->getOutputBuffer<int32_t>(kOutputTensor), in executeDiv()
666 context->getOutputShape(kOutputTensor), [](int32_t a, int32_t b) { in executeDiv()