ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert_micro::import::helpers Namespace Reference

Functions

OMStatus configure_arg_kernel_common (const OMConfigureArgs &config_args)
 
OMStatus configure_SISO_kernel (const OMConfigureArgs &config_args)
 
OMStatus configure_TISO_kernel (const OMConfigureArgs &config_args)
 
OMStatus configure_floor_kernel_common (const OMConfigureArgs &config_args)
 
OMStatus configure_pad_kernel_common (const OMConfigureArgs &config_args)
 
OMStatus configure_pooling_kernel_common (const OMConfigureArgs &config_args)
 
OMStatus configure_spaces_batches_nd_kernel_common (const OMConfigureArgs &config_args)
 

Function Documentation

◆ configure_arg_kernel_common()

OMStatus onert_micro::import::helpers::configure_arg_kernel_common ( const OMConfigureArgs config_args)

Definition at line 32 of file OMArgCommon.cpp.

33{
34 OMRuntimeContext &runtime_context = config_args.runtime_context;
35 uint16_t op_index = config_args.kernel_index;
36
38
39 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
40 if (status != Ok)
41 return status;
42
43 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
44 assert(output != nullptr);
45 const circle::Tensor *input1 = runtime_kernel.inputs[input1TensorIdx];
46 assert(input1 != nullptr);
47 const circle::Tensor *input2 = runtime_kernel.inputs[input2TensorIdx];
48 assert(input2 != nullptr);
49
50 const OMRuntimeShape input2_shape(input2);
51
52 // dim tensor must be a scalar or has one element
53 status =
54 utils::checkCondition(input2_shape.dimensionsCount() == 0 or input2_shape.flatSize() == 1);
55 if (status != Ok)
56 return status;
57
58 // value and output type must match
59 status = utils::checkCondition(output->type() == circle::TensorType_INT32);
60 if (status != Ok)
61 return status;
62 status = utils::checkCondition(input2->type() == circle::TensorType_INT32);
63 if (status != Ok)
64 return status;
65
66 status = utils::checkCondition(input1->type() != circle::TensorType_INT8 and
67 input1->type() != circle::TensorType_INT16);
68 if (status != Ok)
69 return status;
70
71 return status;
72}
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]
core::OMRuntimeContext & runtime_context

References onert_micro::core::OMRuntimeShape::dimensionsCount(), onert_micro::core::OMRuntimeShape::flatSize(), onert_micro::execute::OMRuntimeKernel::inputs, onert_micro::import::OMConfigureArgs::kernel_index, onert_micro::Ok, onert_micro::execute::OMRuntimeKernel::outputs, onert_micro::execute::OMRuntimeKernel::readKernel(), and onert_micro::import::OMConfigureArgs::runtime_context.

◆ configure_floor_kernel_common()

OMStatus onert_micro::import::helpers::configure_floor_kernel_common ( const OMConfigureArgs config_args)

Definition at line 32 of file OMFloorCommon.cpp.

33{
34 OMRuntimeContext &runtime_context = config_args.runtime_context;
35 uint16_t op_index = config_args.kernel_index;
36
38
39 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
40 if (status != Ok)
41 return status;
42
43 const circle::Tensor *input1 = runtime_kernel.inputs[input1TensorIdx];
44 const circle::Tensor *input2 = runtime_kernel.inputs[input2TensorIdx];
45 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
46
47 assert(input1 != nullptr);
48 assert(input2 != nullptr);
49 assert(output != nullptr);
50
51 status = utils::checkCondition(input1->type() == input2->type());
52 if (status != Ok)
53 return status;
54
55 status = utils::checkCondition(input1->type() == output->type());
56 if (status != Ok)
57 return status;
58
59 if (input1->type() != circle::TensorType_INT8 and input1->type() != circle::TensorType_INT16)
60 return status;
61
62 // Check quantization params
63 if (input1->quantization() == nullptr or input2->quantization() == nullptr or
64 output->quantization() == nullptr)
65 {
66 return NoQuantization;
67 }
68
69 if (input1->quantization()->scale()->size() != 1 or
70 input2->quantization()->scale()->size() != 1 or output->quantization()->scale()->size() != 1)
71 {
72 return UnsupportedType;
73 }
74
75 return status;
76}
@ UnsupportedType
Definition OMStatus.h:26
@ NoQuantization
Definition OMStatus.h:33

References onert_micro::execute::OMRuntimeKernel::inputs, onert_micro::import::OMConfigureArgs::kernel_index, onert_micro::NoQuantization, onert_micro::Ok, onert_micro::execute::OMRuntimeKernel::outputs, onert_micro::execute::OMRuntimeKernel::readKernel(), onert_micro::import::OMConfigureArgs::runtime_context, and onert_micro::UnsupportedType.

◆ configure_pad_kernel_common()

OMStatus onert_micro::import::helpers::configure_pad_kernel_common ( const OMConfigureArgs config_args)

Definition at line 33 of file OMPadCommon.cpp.

34{
35 OMRuntimeContext &runtime_context = config_args.runtime_context;
36 OMRuntimeStorage &runtime_storage = config_args.runtime_storage;
37 uint16_t op_index = config_args.kernel_index;
38
40
41 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
42 if (status != Ok)
43 return status;
44
45 const circle::Tensor *input1 = runtime_kernel.inputs[input1TensorIdx];
46 const circle::Tensor *input2 = runtime_kernel.inputs[input2TensorIdx];
47 const circle::Tensor *input3 = runtime_kernel.inputs[input3TensorIdx];
48 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
49
50 assert(input1 != nullptr);
51 assert(input2 != nullptr);
52 assert(output != nullptr);
53
54 status = utils::checkCondition(input1->type() == output->type());
55 if (status != Ok)
56 return status;
57
58 status = utils::checkCondition(input2->type() == circle::TensorType_INT32);
59 if (status != Ok)
60 return status;
61
62 if (input3 != nullptr)
63 {
64 status = utils::checkCondition(input3->type() == input1->type());
65 if (status != Ok)
66 return status;
67
68 // Value is scalar
69 status = utils::checkCondition(OMRuntimeShape(input3).flatSize() == 1);
70 if (status != Ok)
71 return status;
72 }
73
74 return Ok;
75}
core::OMRuntimeStorage & runtime_storage

References onert_micro::execute::OMRuntimeKernel::inputs, onert_micro::import::OMConfigureArgs::kernel_index, onert_micro::Ok, onert_micro::execute::OMRuntimeKernel::outputs, onert_micro::execute::OMRuntimeKernel::readKernel(), onert_micro::import::OMConfigureArgs::runtime_context, and onert_micro::import::OMConfigureArgs::runtime_storage.

◆ configure_pooling_kernel_common()

OMStatus onert_micro::import::helpers::configure_pooling_kernel_common ( const OMConfigureArgs config_args)

Definition at line 31 of file OMPoolingCommon.cpp.

32{
33 OMRuntimeContext &runtime_context = config_args.runtime_context;
34 uint16_t op_index = config_args.kernel_index;
35
37
38 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
39 if (status != Ok)
40 return status;
41
42 const circle::Tensor *input = runtime_kernel.inputs[inputTensorIdx];
43 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
44
45 assert(input != nullptr);
46 assert(output != nullptr);
47
48 status = utils::checkCondition(input->type() == output->type());
49 if (status != Ok)
50 return status;
51
52 OMRuntimeShape input_shape(input);
54
55 status = utils::checkCondition(input_shape.dimensionsCount() == output_shape.dimensionsCount());
56 if (status != Ok)
57 return status;
58
59 status = utils::checkCondition(input_shape.dimensionsCount() == 4);
60
61 auto option = runtime_kernel.first_operator->builtin_options_as_Pool2DOptions();
62
63 if (option == nullptr)
64 return UnknownError;
65
66 assert(option != nullptr);
67
68 if (input->type() != circle::TensorType_INT8 and input->type() != circle::TensorType_INT16)
69 return status;
70
71 // Check quantization params
72 if (input->quantization() == nullptr)
73 {
74 return NoQuantization;
75 }
76
77 if (input->quantization()->scale()->size() != 1)
78 {
79 return UnsupportedType;
80 }
81
82 // Check quantization params
83 if (output->quantization() == nullptr)
84 {
85 return NoQuantization;
86 }
87
88 if (output->quantization()->scale()->size() != 1)
89 {
90 return UnsupportedType;
91 }
92
93 return status;
94}
int32_t dimensionsCount() const
Definition Tensor.h:106
const circle::Operator * first_operator
const luci_interpreter::RuntimeShape output_shape

References luci_interpreter::RuntimeShape::dimensionsCount(), onert_micro::core::OMRuntimeShape::dimensionsCount(), onert_micro::execute::OMRuntimeKernel::first_operator, onert_micro::execute::OMRuntimeKernel::inputs, onert_micro::import::OMConfigureArgs::kernel_index, onert_micro::NoQuantization, onert_micro::Ok, output_shape, onert_micro::execute::OMRuntimeKernel::outputs, onert_micro::execute::OMRuntimeKernel::readKernel(), onert_micro::import::OMConfigureArgs::runtime_context, onert_micro::UnknownError, and onert_micro::UnsupportedType.

◆ configure_SISO_kernel()

OMStatus onert_micro::import::helpers::configure_SISO_kernel ( const OMConfigureArgs config_args)

Definition at line 30 of file OMConfigureSISOKernel.cpp.

31{
32 OMRuntimeContext &runtime_context = config_args.runtime_context;
33 uint16_t op_index = config_args.kernel_index;
34
36
37 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
38 if (status != Ok)
39 return status;
40
41 const circle::Tensor *input = runtime_kernel.inputs[inputTensorIdx];
42 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
43
44 assert(input != nullptr);
45 assert(output != nullptr);
46
47 status = utils::checkCondition(input->type() == output->type());
48 if (status != Ok)
49 return status;
50
51 OMRuntimeShape input_shape(input);
53
54 status = utils::checkCondition(input_shape == output_shape);
55
56 if (input->type() != circle::TensorType_INT8 and input->type() != circle::TensorType_INT16)
57 return status;
58
59 // Check quantized version
60 if (input->quantization() == nullptr or output->quantization() == nullptr)
61 return NoQuantization;
62
63 if (output->quantization()->scale() == nullptr or output->quantization()->scale()->size() != 1)
65
66 if (input->quantization()->zero_point() == nullptr or
67 input->quantization()->zero_point()->size() != 1)
69
70 return status;
71}
@ UnsupportedQuantizationType
Definition OMStatus.h:27

References onert_micro::execute::OMRuntimeKernel::inputs, onert_micro::import::OMConfigureArgs::kernel_index, onert_micro::NoQuantization, onert_micro::Ok, output_shape, onert_micro::execute::OMRuntimeKernel::outputs, onert_micro::execute::OMRuntimeKernel::readKernel(), onert_micro::import::OMConfigureArgs::runtime_context, and onert_micro::UnsupportedQuantizationType.

◆ configure_spaces_batches_nd_kernel_common()

OMStatus onert_micro::import::helpers::configure_spaces_batches_nd_kernel_common ( const OMConfigureArgs config_args)

Definition at line 32 of file OMSpacesBatchesNDCommon.cpp.

34{
35 OMRuntimeContext &runtime_context = config_args.runtime_context;
36 uint16_t op_index = config_args.kernel_index;
37
39
40 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
41 if (status != Ok)
42 return status;
43
44 const circle::Tensor *input1 = runtime_kernel.inputs[input1TensorIdx];
45 const circle::Tensor *input2 = runtime_kernel.inputs[input2TensorIdx];
46 const circle::Tensor *input3 = runtime_kernel.inputs[input3TensorIdx];
47 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
48
49 core::OMRuntimeShape input1_shape(input1);
51
52 assert(input1 != nullptr);
53 assert(input2 != nullptr);
54 assert(input3 != nullptr);
55 assert(output != nullptr);
56
57 status = utils::checkCondition(input1->type() == output->type());
58 if (status != Ok)
59 return status;
60
61 status = utils::checkCondition(input2->type() == circle::TensorType_INT32);
62 if (status != Ok)
63 return status;
64
65 status = utils::checkCondition(input3->type() == circle::TensorType_INT32);
66 if (status != Ok)
67 return status;
68
69 status = utils::checkCondition(output_shape.dimensionsCount() >= 3);
70 if (status != Ok)
71 return status;
72
73 status = utils::checkCondition(input1_shape.dimensionsCount() >= 3);
74 if (status != Ok)
75 return status;
76
77 status = utils::checkCondition(output_shape.dimensionsCount() <= 4);
78 if (status != Ok)
79 return status;
80
81 status = utils::checkCondition(input1_shape.dimensionsCount() <= 4);
82 if (status != Ok)
83 return status;
84
85 return status;
86}

References luci_interpreter::RuntimeShape::dimensionsCount(), onert_micro::core::OMRuntimeShape::dimensionsCount(), onert_micro::execute::OMRuntimeKernel::inputs, onert_micro::import::OMConfigureArgs::kernel_index, onert_micro::Ok, output_shape, onert_micro::execute::OMRuntimeKernel::outputs, onert_micro::execute::OMRuntimeKernel::readKernel(), and onert_micro::import::OMConfigureArgs::runtime_context.

◆ configure_TISO_kernel()

OMStatus onert_micro::import::helpers::configure_TISO_kernel ( const OMConfigureArgs config_args)

Definition at line 32 of file OMConfigureTISOKernel.cpp.

33{
34 OMRuntimeContext &runtime_context = config_args.runtime_context;
35 uint16_t op_index = config_args.kernel_index;
36
38
39 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
40 if (status != Ok)
41 return status;
42
43 const circle::Tensor *input1 = runtime_kernel.inputs[input1TensorIdx];
44 const circle::Tensor *input2 = runtime_kernel.inputs[input2TensorIdx];
45 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
46
47 assert(input1 != nullptr);
48 assert(input2 != nullptr);
49 assert(output != nullptr);
50
51 status = utils::checkCondition(input1->type() == output->type());
52 if (status != Ok)
53 return status;
54
55 status = utils::checkCondition(input2->type() == output->type());
56 if (status != Ok)
57 return status;
58
59 if (input1->type() != circle::TensorType_INT8 and input1->type() != circle::TensorType_INT16)
60 return status;
61
62#ifndef DIS_QUANT
63
64 // Check quantization params
65 if (input1->quantization() == nullptr or input2->quantization() == nullptr or
66 output->quantization() == nullptr)
67 {
68 return NoQuantization;
69 }
70
71 if (input1->quantization()->scale() == nullptr or
72 input1->quantization()->zero_point() == nullptr or
73 input1->quantization()->scale()->size() != 1 or
74 input1->quantization()->zero_point()->size() != 1)
75 {
76 return NoQuantization;
77 }
78
79 if (input2->quantization()->scale() == nullptr or
80 input2->quantization()->zero_point() == nullptr or
81 input2->quantization()->scale()->size() != 1 or
82 input2->quantization()->zero_point()->size() != 1)
83 {
84 return NoQuantization;
85 }
86
87 if (output->quantization()->scale() == nullptr or
88 output->quantization()->zero_point() == nullptr or
89 output->quantization()->scale()->size() != 1 or
90 output->quantization()->zero_point()->size() != 1)
91 {
92 return NoQuantization;
93 }
94
95#endif // DIS_QUANT
96
97 return status;
98}

References onert_micro::execute::OMRuntimeKernel::inputs, onert_micro::import::OMConfigureArgs::kernel_index, onert_micro::NoQuantization, onert_micro::Ok, onert_micro::execute::OMRuntimeKernel::outputs, onert_micro::execute::OMRuntimeKernel::readKernel(), and onert_micro::import::OMConfigureArgs::runtime_context.