Skip to content

Commit

Permalink
[onert-micro] use exec sisoheader for quantize kernels (#13924)
Browse files Browse the repository at this point in the history
* [onert-micro] use exec sisoheader for quantize kernels

- Use exec SISO header for quantize/dequantize kernel

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

* use exec sisoheader for quantize kernels

- Use exec SISO header for quantize/dequantize kernel

ONE-DCO-1.0-Signed-off-by: Chunseok Lee <[email protected]>
  • Loading branch information
chunseoklee authored Sep 5, 2024
1 parent 487afbd commit 9b774ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 77 deletions.
30 changes: 4 additions & 26 deletions onert-micro/onert-micro/src/execute/kernels/Dequantize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "PALDequantize.h"
#include "core/OMRuntimeShape.h"

#include "execute/OMUtils.h"

using namespace onert_micro;
using namespace onert_micro::execute;

Expand All @@ -35,41 +37,17 @@ constexpr uint32_t outputTensorIdx = 0;
// NOTE: doesnt currently support dynamic shapes
OMStatus onert_micro::execute::execute_kernel_CircleDequantize(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;

const circle::Tensor *input = nullptr;
const circle::Tensor *output = nullptr;

uint8_t *input_data = nullptr;
uint8_t *output_data = nullptr;

OMStatus status = Ok;

{
OMRuntimeKernel runtime_kernel;
runtime_kernel.readKernel(op_index, runtime_context);

input = runtime_kernel.inputs[inputTensorIdx];
output = runtime_kernel.outputs[outputTensorIdx];

assert(input != nullptr);
assert(output != nullptr);

status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context);
if (status != Ok)
return status;

input_data = runtime_kernel.inputs_data[inputTensorIdx];
output_data = runtime_kernel.outputs_data[outputTensorIdx];
}

assert(input_data != nullptr);
assert(output_data != nullptr);
SISOHeader(execute_args, &input, &output, &input_data, &output_data);

assert(output->type() == circle::TensorType_FLOAT32);

OMStatus status = Ok;
switch (input->type())
{
#ifndef DIS_FLOAT
Expand Down
30 changes: 4 additions & 26 deletions onert-micro/onert-micro/src/execute/kernels/MathCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "execute/kernels/MathCommon.h"

#include "execute/OMUtils.h"

using namespace onert_micro;
using namespace onert_micro::execute;

Expand All @@ -33,39 +35,15 @@ OMStatus onert_micro::execute::execute_math_common(
const std::function<OMStatus(const core::OMRuntimeShape &, const float *,
const core::OMRuntimeShape &, float *)> &f_float)
{
core::OMRuntimeContext &runtime_context = execute_args.runtime_context;
core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage;
uint16_t op_index = execute_args.kernel_index;

const circle::Tensor *input = nullptr;
const circle::Tensor *output = nullptr;

uint8_t *input_data = nullptr;
uint8_t *output_data = nullptr;

OMStatus status = Ok;

{
OMRuntimeKernel runtime_kernel;
runtime_kernel.readKernel(op_index, runtime_context);

input = runtime_kernel.inputs[inputTensorIdx];
output = runtime_kernel.outputs[outputTensorIdx];

assert(input != nullptr);
assert(output != nullptr);

status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context);
if (status != Ok)
return status;

input_data = runtime_kernel.inputs_data[inputTensorIdx];
output_data = runtime_kernel.outputs_data[outputTensorIdx];
}

assert(input_data != nullptr);
assert(output_data != nullptr);
SISOHeader(execute_args, &input, &output, &input_data, &output_data);

OMStatus status;
switch (input->type())
{
#ifndef DIS_FLOAT
Expand Down
29 changes: 4 additions & 25 deletions onert-micro/onert-micro/src/execute/kernels/Quantize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include "PALQuantize.h"

#include "execute/OMUtils.h"

using namespace onert_micro;
using namespace onert_micro::execute;

Expand All @@ -36,38 +38,15 @@ constexpr uint32_t outputTensorIdx = 0;
// NOTE: doesnt currently support dynamic shapes
OMStatus onert_micro::execute::execute_kernel_CircleQuantize(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;

const circle::Tensor *input = nullptr;
const circle::Tensor *output = nullptr;

uint8_t *input_data = nullptr;
uint8_t *output_data = nullptr;

OMStatus status = Ok;

{
OMRuntimeKernel runtime_kernel;
runtime_kernel.readKernel(op_index, runtime_context);

input = runtime_kernel.inputs[inputTensorIdx];
output = runtime_kernel.outputs[outputTensorIdx];
SISOHeader(execute_args, &input, &output, &input_data, &output_data);

assert(input != nullptr);
assert(output != nullptr);

status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context);
if (status != Ok)
return status;

input_data = runtime_kernel.inputs_data[inputTensorIdx];
output_data = runtime_kernel.outputs_data[outputTensorIdx];
}

assert(input_data != nullptr);
assert(output_data != nullptr);
OMStatus status = Ok;

assert(input->type() == circle::TensorType_FLOAT32);

Expand Down

0 comments on commit 9b774ce

Please sign in to comment.