diff --git a/onert-micro/onert-micro/include/execute/OMUtils.h b/onert-micro/onert-micro/include/execute/OMUtils.h index b45feb08953..109dbea23fa 100644 --- a/onert-micro/onert-micro/include/execute/OMUtils.h +++ b/onert-micro/onert-micro/include/execute/OMUtils.h @@ -163,6 +163,10 @@ void calculateQuantParams(core::ArithmeticQuantParams ¶ms, const circle::Ten OMStatus SISOHeader(const OMExecuteArgs &execute_args, const circle::Tensor **input, const circle::Tensor **output, uint8_t **input_data, uint8_t **output_data); +OMStatus TISOHeader(const OMExecuteArgs &execute_args, const circle::Tensor **input1, + const circle::Tensor **input2, const circle::Tensor **output, + OMRuntimeKernel *runtime_kernel); + } // namespace execute } // namespace onert_micro diff --git a/onert-micro/onert-micro/src/execute/OMUtils.cpp b/onert-micro/onert-micro/src/execute/OMUtils.cpp index 9bda002018c..1fca5d95331 100644 --- a/onert-micro/onert-micro/src/execute/OMUtils.cpp +++ b/onert-micro/onert-micro/src/execute/OMUtils.cpp @@ -236,3 +236,32 @@ void onert_micro::execute::calculateQuantParams(core::ArithmeticQuantParams &par ¶ms.quantized_activation_min, ¶ms.quantized_activation_max); } + +OMStatus onert_micro::execute::TISOHeader(const OMExecuteArgs &execute_args, + const circle::Tensor **input1, + const circle::Tensor **input2, + const circle::Tensor **output, + OMRuntimeKernel *runtime_kernel) +{ + OMStatus status; + + core::OMRuntimeContext &runtime_context = execute_args.runtime_context; + core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage; + uint16_t op_index = execute_args.kernel_index; + + status = runtime_kernel->readKernel(op_index, runtime_context); + + *input1 = runtime_kernel->inputs[0]; + *input2 = runtime_kernel->inputs[1]; + *output = runtime_kernel->outputs[0]; + + assert(*input1 != nullptr); + assert(*input2 != nullptr); + assert(*output != nullptr); + + status = runtime_kernel->getDataFromStorage(op_index, runtime_storage, runtime_context); + if (status != Ok) + return status; + + return status; +} diff --git a/onert-micro/onert-micro/src/execute/kernels/Equal.cpp b/onert-micro/onert-micro/src/execute/kernels/Equal.cpp index 0ff8ca8443d..4c7a6177176 100644 --- a/onert-micro/onert-micro/src/execute/kernels/Equal.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/Equal.cpp @@ -21,6 +21,8 @@ #include "execute/kernels/ComparisonCommon.h" #include "PALComparisons.h" +#include "execute/OMUtils.h" + using namespace onert_micro; using namespace onert_micro::core; using namespace onert_micro::execute; @@ -36,10 +38,6 @@ constexpr uint32_t outputTensorIdx = 0; OMStatus onert_micro::execute::execute_kernel_CircleEqual(const OMExecuteArgs &execute_args) { - core::OMRuntimeContext &runtime_context = execute_args.runtime_context; - core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage; - uint16_t op_index = execute_args.kernel_index; - OMStatus status = Ok; const circle::Tensor *input1 = nullptr; @@ -47,19 +45,8 @@ OMStatus onert_micro::execute::execute_kernel_CircleEqual(const OMExecuteArgs &e const circle::Tensor *output = nullptr; OMRuntimeKernel runtime_kernel; - runtime_kernel.readKernel(op_index, runtime_context); - - status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context); - if (status != Ok) - return status; - - input1 = runtime_kernel.inputs[input1TensorIdx]; - input2 = runtime_kernel.inputs[input2TensorIdx]; - output = runtime_kernel.outputs[outputTensorIdx]; - assert(input1 != nullptr); - assert(input2 != nullptr); - assert(output != nullptr); + TISOHeader(execute_args, &input1, &input2, &output, &runtime_kernel); switch (input1->type()) { diff --git a/onert-micro/onert-micro/src/execute/kernels/Greater.cpp b/onert-micro/onert-micro/src/execute/kernels/Greater.cpp index 5f95c0e0a79..82feefc148f 100644 --- a/onert-micro/onert-micro/src/execute/kernels/Greater.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/Greater.cpp @@ -21,6 +21,8 @@ #include "execute/kernels/ComparisonCommon.h" #include "PALComparisons.h" +#include "execute/OMUtils.h" + using namespace onert_micro; using namespace onert_micro::core; using namespace onert_micro::execute; @@ -36,10 +38,6 @@ constexpr uint32_t outputTensorIdx = 0; OMStatus onert_micro::execute::execute_kernel_CircleGreater(const OMExecuteArgs &execute_args) { - core::OMRuntimeContext &runtime_context = execute_args.runtime_context; - core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage; - uint16_t op_index = execute_args.kernel_index; - OMStatus status = Ok; const circle::Tensor *input1 = nullptr; @@ -47,19 +45,8 @@ OMStatus onert_micro::execute::execute_kernel_CircleGreater(const OMExecuteArgs const circle::Tensor *output = nullptr; OMRuntimeKernel runtime_kernel; - runtime_kernel.readKernel(op_index, runtime_context); - - status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context); - if (status != Ok) - return status; - - input1 = runtime_kernel.inputs[input1TensorIdx]; - input2 = runtime_kernel.inputs[input2TensorIdx]; - output = runtime_kernel.outputs[outputTensorIdx]; - assert(input1 != nullptr); - assert(input2 != nullptr); - assert(output != nullptr); + TISOHeader(execute_args, &input1, &input2, &output, &runtime_kernel); switch (input1->type()) { diff --git a/onert-micro/onert-micro/src/execute/kernels/GreaterEqual.cpp b/onert-micro/onert-micro/src/execute/kernels/GreaterEqual.cpp index 325e332f838..70255d919f2 100644 --- a/onert-micro/onert-micro/src/execute/kernels/GreaterEqual.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/GreaterEqual.cpp @@ -21,6 +21,8 @@ #include "execute/kernels/ComparisonCommon.h" #include "PALComparisons.h" +#include "execute/OMUtils.h" + using namespace onert_micro; using namespace onert_micro::core; using namespace onert_micro::execute; @@ -36,10 +38,6 @@ constexpr uint32_t outputTensorIdx = 0; OMStatus onert_micro::execute::execute_kernel_CircleGreaterEqual(const OMExecuteArgs &execute_args) { - core::OMRuntimeContext &runtime_context = execute_args.runtime_context; - core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage; - uint16_t op_index = execute_args.kernel_index; - OMStatus status = Ok; const circle::Tensor *input1 = nullptr; @@ -47,19 +45,8 @@ OMStatus onert_micro::execute::execute_kernel_CircleGreaterEqual(const OMExecute const circle::Tensor *output = nullptr; OMRuntimeKernel runtime_kernel; - runtime_kernel.readKernel(op_index, runtime_context); - - status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context); - if (status != Ok) - return status; - - input1 = runtime_kernel.inputs[input1TensorIdx]; - input2 = runtime_kernel.inputs[input2TensorIdx]; - output = runtime_kernel.outputs[outputTensorIdx]; - assert(input1 != nullptr); - assert(input2 != nullptr); - assert(output != nullptr); + TISOHeader(execute_args, &input1, &input2, &output, &runtime_kernel); switch (input1->type()) { diff --git a/onert-micro/onert-micro/src/execute/kernels/Less.cpp b/onert-micro/onert-micro/src/execute/kernels/Less.cpp index b815849cf6f..a7a3b2f9d9b 100644 --- a/onert-micro/onert-micro/src/execute/kernels/Less.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/Less.cpp @@ -21,6 +21,8 @@ #include "execute/kernels/ComparisonCommon.h" #include "PALComparisons.h" +#include "execute/OMUtils.h" + using namespace onert_micro; using namespace onert_micro::core; using namespace onert_micro::execute; @@ -36,10 +38,6 @@ constexpr uint32_t outputTensorIdx = 0; OMStatus onert_micro::execute::execute_kernel_CircleLess(const OMExecuteArgs &execute_args) { - core::OMRuntimeContext &runtime_context = execute_args.runtime_context; - core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage; - uint16_t op_index = execute_args.kernel_index; - OMStatus status = Ok; const circle::Tensor *input1 = nullptr; @@ -47,19 +45,8 @@ OMStatus onert_micro::execute::execute_kernel_CircleLess(const OMExecuteArgs &ex const circle::Tensor *output = nullptr; OMRuntimeKernel runtime_kernel; - runtime_kernel.readKernel(op_index, runtime_context); - - status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context); - if (status != Ok) - return status; - - input1 = runtime_kernel.inputs[input1TensorIdx]; - input2 = runtime_kernel.inputs[input2TensorIdx]; - output = runtime_kernel.outputs[outputTensorIdx]; - assert(input1 != nullptr); - assert(input2 != nullptr); - assert(output != nullptr); + TISOHeader(execute_args, &input1, &input2, &output, &runtime_kernel); switch (input1->type()) { diff --git a/onert-micro/onert-micro/src/execute/kernels/NotEqual.cpp b/onert-micro/onert-micro/src/execute/kernels/NotEqual.cpp index 5591c3eb76c..b2c8bc97ad2 100644 --- a/onert-micro/onert-micro/src/execute/kernels/NotEqual.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/NotEqual.cpp @@ -21,6 +21,8 @@ #include "execute/kernels/ComparisonCommon.h" #include "PALComparisons.h" +#include "execute/OMUtils.h" + using namespace onert_micro; using namespace onert_micro::core; using namespace onert_micro::execute; @@ -36,10 +38,6 @@ constexpr uint32_t outputTensorIdx = 0; OMStatus onert_micro::execute::execute_kernel_CircleNotEqual(const OMExecuteArgs &execute_args) { - core::OMRuntimeContext &runtime_context = execute_args.runtime_context; - core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage; - uint16_t op_index = execute_args.kernel_index; - OMStatus status = Ok; const circle::Tensor *input1 = nullptr; @@ -47,19 +45,8 @@ OMStatus onert_micro::execute::execute_kernel_CircleNotEqual(const OMExecuteArgs const circle::Tensor *output = nullptr; OMRuntimeKernel runtime_kernel; - runtime_kernel.readKernel(op_index, runtime_context); - - status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context); - if (status != Ok) - return status; - - input1 = runtime_kernel.inputs[input1TensorIdx]; - input2 = runtime_kernel.inputs[input2TensorIdx]; - output = runtime_kernel.outputs[outputTensorIdx]; - assert(input1 != nullptr); - assert(input2 != nullptr); - assert(output != nullptr); + TISOHeader(execute_args, &input1, &input2, &output, &runtime_kernel); switch (input1->type()) {