-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[onert-micro] Floor Common Helper (#13843)
- helper for floordiv and floormod ONE-DCO-1.0-Signed-off-by: Chunseok Lee <[email protected]>
- Loading branch information
1 parent
d6c85fb
commit 2624ca2
Showing
5 changed files
with
119 additions
and
94 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
onert-micro/onert-micro/include/import/helpers/OMFloorCommon.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef ONERT_MICRO_IMPORT_HELPERS_CONFIGURE_FLOOR_KERNEL_COMMON_H | ||
#define ONERT_MICRO_IMPORT_HELPERS_CONFIGURE_FLOOR_KERNEL_COMMON_H | ||
|
||
#include "import/OMKernelConfigureBuilder.h" | ||
#include "core/OMUtils.h" | ||
#include "OMStatus.h" | ||
#include "execute/OMRuntimeKernel.h" | ||
|
||
namespace onert_micro | ||
{ | ||
namespace import | ||
{ | ||
namespace helpers | ||
{ | ||
|
||
OMStatus configure_floor_kernel_common(const OMConfigureArgs &config_args); | ||
|
||
} // namespace helpers | ||
} // namespace import | ||
} // namespace onert_micro | ||
|
||
#endif // ONERT_MICRO_IMPORT_HELPERS_CONFIGURE_FLOOR_KERNEL_COMMON_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
onert-micro/onert-micro/src/import/helpers/OMFloorCommon.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "import/helpers/OMFloorCommon.h" | ||
|
||
using namespace onert_micro; | ||
using namespace onert_micro::core; | ||
|
||
namespace | ||
{ | ||
|
||
constexpr uint32_t input1TensorIdx = 0; | ||
constexpr uint32_t input2TensorIdx = 1; | ||
constexpr uint32_t outputTensorIdx = 0; | ||
|
||
} // namespace | ||
|
||
OMStatus | ||
onert_micro::import::helpers::configure_floor_kernel_common(const OMConfigureArgs &config_args) | ||
{ | ||
OMRuntimeContext &runtime_context = config_args.runtime_context; | ||
uint16_t op_index = config_args.kernel_index; | ||
|
||
onert_micro::execute::OMRuntimeKernel runtime_kernel; | ||
|
||
OMStatus status = runtime_kernel.readKernel(op_index, runtime_context); | ||
if (status != Ok) | ||
return status; | ||
|
||
const circle::Tensor *input1 = runtime_kernel.inputs[input1TensorIdx]; | ||
const circle::Tensor *input2 = runtime_kernel.inputs[input2TensorIdx]; | ||
const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx]; | ||
|
||
assert(input1 != nullptr); | ||
assert(input2 != nullptr); | ||
assert(output != nullptr); | ||
|
||
status = utils::checkCondition(input1->type() == input2->type()); | ||
if (status != Ok) | ||
return status; | ||
|
||
status = utils::checkCondition(input1->type() == output->type()); | ||
if (status != Ok) | ||
return status; | ||
|
||
if (input1->type() != circle::TensorType_INT8 and input1->type() != circle::TensorType_INT16) | ||
return status; | ||
|
||
// Check quantization params | ||
if (input1->quantization() == nullptr or input2->quantization() == nullptr or | ||
output->quantization() == nullptr) | ||
{ | ||
return NoQuantization; | ||
} | ||
|
||
if (input1->quantization()->scale()->size() != 1 or | ||
input2->quantization()->scale()->size() != 1 or output->quantization()->scale()->size() != 1) | ||
{ | ||
return UnsupportedType; | ||
} | ||
|
||
return status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters