Skip to content

Commit

Permalink
TISO header helper for comparison op (#13928)
Browse files Browse the repository at this point in the history
* TISO header helper for comparison op

- tiso header helper defined
- apply this to comparison ops

ONE-DCO-1.0-Signed-off-by: Chunseok Lee <[email protected]>

* fix format
  • Loading branch information
chunseoklee authored Sep 9, 2024
1 parent a32ce46 commit c3f130e
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 80 deletions.
4 changes: 4 additions & 0 deletions onert-micro/onert-micro/include/execute/OMUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ void calculateQuantParams(core::ArithmeticQuantParams &params, 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

Expand Down
29 changes: 29 additions & 0 deletions onert-micro/onert-micro/src/execute/OMUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,32 @@ void onert_micro::execute::calculateQuantParams(core::ArithmeticQuantParams &par
&params.quantized_activation_min,
&params.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;
}
19 changes: 3 additions & 16 deletions onert-micro/onert-micro/src/execute/kernels/Equal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,30 +38,15 @@ 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;
const circle::Tensor *input2 = nullptr;
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())
{
Expand Down
19 changes: 3 additions & 16 deletions onert-micro/onert-micro/src/execute/kernels/Greater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,30 +38,15 @@ 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;
const circle::Tensor *input2 = nullptr;
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())
{
Expand Down
19 changes: 3 additions & 16 deletions onert-micro/onert-micro/src/execute/kernels/GreaterEqual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,30 +38,15 @@ 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;
const circle::Tensor *input2 = nullptr;
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())
{
Expand Down
19 changes: 3 additions & 16 deletions onert-micro/onert-micro/src/execute/kernels/Less.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,30 +38,15 @@ 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;
const circle::Tensor *input2 = nullptr;
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())
{
Expand Down
19 changes: 3 additions & 16 deletions onert-micro/onert-micro/src/execute/kernels/NotEqual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,30 +38,15 @@ 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;
const circle::Tensor *input2 = nullptr;
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())
{
Expand Down

0 comments on commit c3f130e

Please sign in to comment.