-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[onert-micro] Introduce Floor kernel (#11571)
This commit introduces Floor kernel. ONE-DCO-1.0-Signed-off-by: Vyacheslav Bazhenov <[email protected]> Co-authored-by: Vyacheslav Bazhenov <[email protected]>
- Loading branch information
1 parent
212a984
commit d5b3e12
Showing
9 changed files
with
473 additions
and
106 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
onert-micro/luci-interpreter/include/luci_interpreter/test_models/floor/FloatFloorKernel.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,85 @@ | ||
/* | ||
* Copyright (c) 2023 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 LUCI_INTERPRETER_TEST_MODELS_FLOAT_FLOOR_KERNEL_H | ||
#define LUCI_INTERPRETER_TEST_MODELS_FLOAT_FLOOR_KERNEL_H | ||
|
||
#include "TestDataFloorBase.h" | ||
|
||
namespace luci_interpreter | ||
{ | ||
namespace test_kernel | ||
{ | ||
namespace floor_float | ||
{ | ||
/* | ||
* Floor Kernel: | ||
* | ||
* Input(2, 3) | ||
* | | ||
* Floor | ||
* | | ||
* Output(2, 3) | ||
*/ | ||
unsigned char test_kernel_model_circle[] = { | ||
0x1c, 0x00, 0x00, 0x00, 0x43, 0x49, 0x52, 0x30, 0x00, 0x00, 0x12, 0x00, 0x18, 0x00, 0x00, 0x00, | ||
0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x12, 0x00, 0x00, 0x00, | ||
0x38, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, | ||
0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x28, 0x01, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, | ||
0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6e, 0x6e, 0x70, 0x61, | ||
0x63, 0x6b, 0x61, 0x67, 0x65, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | ||
0x0c, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x14, 0x00, | ||
0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | ||
0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, | ||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | ||
0x64, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x00, 0x00, | ||
0x04, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0xd8, 0xff, 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x03, 0x00, 0x00, 0x00, 0x6f, 0x66, 0x6d, 0x00, 0xbc, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, | ||
0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x08, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x69, 0x66, 0x6d, 0x00, 0xf0, 0xff, 0xff, 0xff, | ||
0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, | ||
0x04, 0x00, 0x00, 0x00}; | ||
|
||
const std::vector<float> input_data = {7.297842, 30.999863, 15.692827, | ||
-18.824865, 22.614136, 5.7466774}; | ||
|
||
const std::vector<float> reference_output_data = {7, 30, 15, -19, 22, 5}; | ||
|
||
} // namespace floor_float | ||
|
||
class TestDataFloatFloor : public TestDataFloorBase<float> | ||
{ | ||
public: | ||
TestDataFloatFloor() | ||
{ | ||
_input_data = floor_float::input_data; | ||
_reference_output_data = floor_float::reference_output_data; | ||
_test_kernel_model_circle = floor_float::test_kernel_model_circle; | ||
} | ||
|
||
~TestDataFloatFloor() override = default; | ||
}; | ||
|
||
} // namespace test_kernel | ||
} // namespace luci_interpreter | ||
|
||
#endif // LUCI_INTERPRETER_TEST_MODELS_FLOAT_FLOOR_KERNEL_H |
143 changes: 143 additions & 0 deletions
143
onert-micro/luci-interpreter/include/luci_interpreter/test_models/floor/NegFloorKernel.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,143 @@ | ||
/* | ||
* Copyright (c) 2023 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 LUCI_INTERPRETER_TEST_MODELS_NEG_FLOOR_KERNEL_H | ||
#define LUCI_INTERPRETER_TEST_MODELS_NEG_FLOOR_KERNEL_H | ||
|
||
#include "TestDataFloorBase.h" | ||
|
||
namespace luci_interpreter | ||
{ | ||
namespace test_kernel | ||
{ | ||
namespace neg_input_output_type_mismatch_floor_kernel | ||
{ | ||
/* | ||
* Floor Kernel with input output type mismatch (should be equal): | ||
* | ||
* Input(2, 3) - Uint8 | ||
* | | ||
* Floor | ||
* | | ||
* Output(2, 3) - Float | ||
*/ | ||
const unsigned char test_kernel_model_circle[] = { | ||
0x18, 0x00, 0x00, 0x00, 0x43, 0x49, 0x52, 0x30, 0x00, 0x00, 0x0e, 0x00, 0x14, 0x00, 0x00, 0x00, | ||
0x0c, 0x00, 0x08, 0x00, 0x10, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | ||
0x2c, 0x00, 0x00, 0x00, 0x64, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | ||
0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, | ||
0xfc, 0xff, 0xff, 0xff, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0c, 0x00, | ||
0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, | ||
0x48, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, | ||
0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, | ||
0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, | ||
0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, | ||
0x03, 0x00, 0x00, 0x00, 0x6f, 0x66, 0x6d, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | ||
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x14, 0x00, 0x13, 0x00, 0x0c, 0x00, | ||
0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x54, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, | ||
0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, | ||
0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x81, 0x80, 0x00, 0x3c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x80, 0xbf, 0x03, 0x00, 0x00, 0x00, 0x69, 0x66, 0x6d, 0x00, 0x02, 0x00, 0x00, 0x00, | ||
0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | ||
0x0c, 0x00, 0x0c, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, | ||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x11, 0x00, 0x00, 0x00, 0x4f, 0x4e, 0x45, 0x2d, | ||
0x74, 0x66, 0x6c, 0x69, 0x74, 0x65, 0x32, 0x63, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x00, 0x00, 0x00}; | ||
|
||
} // namespace neg_input_output_type_mismatch_floor_kernel | ||
|
||
namespace neg_invalid_input_output_shape_floor_kernel | ||
{ | ||
/* | ||
* Floor Kernel with different input output shapes: | ||
* | ||
* Input(1, 2, 3) | ||
* | | ||
* Floor | ||
* | | ||
* Output(2, 3) | ||
*/ | ||
const unsigned char test_kernel_model_circle[] = { | ||
0x18, 0x00, 0x00, 0x00, 0x43, 0x49, 0x52, 0x30, 0x00, 0x00, 0x0e, 0x00, 0x14, 0x00, 0x00, 0x00, | ||
0x0c, 0x00, 0x08, 0x00, 0x10, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | ||
0x2c, 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x24, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | ||
0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, | ||
0xfc, 0xff, 0xff, 0xff, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0c, 0x00, | ||
0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, | ||
0x48, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, | ||
0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, | ||
0x04, 0x00, 0x00, 0x00, 0xdc, 0xff, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | ||
0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6f, 0x66, 0x6d, 0x00, 0x02, 0x00, 0x00, 0x00, | ||
0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, | ||
0x08, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x69, 0x66, 0x6d, 0x00, 0x03, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, | ||
0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x11, 0x00, 0x00, 0x00, | ||
0x4f, 0x4e, 0x45, 0x2d, 0x74, 0x66, 0x6c, 0x69, 0x74, 0x65, 0x32, 0x63, 0x69, 0x72, 0x63, 0x6c, | ||
0x65, 0x00, 0x00, 0x00}; | ||
} // namespace neg_invalid_input_output_shape_floor_kernel | ||
|
||
class NegTestDataInputOutputTypeMismatchFloorKernel : public NegTestDataBase | ||
{ | ||
public: | ||
NegTestDataInputOutputTypeMismatchFloorKernel() | ||
{ | ||
_test_kernel_model_circle = | ||
neg_input_output_type_mismatch_floor_kernel::test_kernel_model_circle; | ||
} | ||
|
||
~NegTestDataInputOutputTypeMismatchFloorKernel() override = default; | ||
|
||
const unsigned char *get_model_ptr() override final { return _test_kernel_model_circle; } | ||
|
||
protected: | ||
const unsigned char *_test_kernel_model_circle; | ||
}; | ||
|
||
class NegTestDataInvalidInputOutputShapeFloorKernel : public NegTestDataBase | ||
{ | ||
public: | ||
NegTestDataInvalidInputOutputShapeFloorKernel() | ||
{ | ||
_test_kernel_model_circle = | ||
neg_invalid_input_output_shape_floor_kernel::test_kernel_model_circle; | ||
} | ||
|
||
~NegTestDataInvalidInputOutputShapeFloorKernel() override = default; | ||
|
||
const unsigned char *get_model_ptr() override final { return _test_kernel_model_circle; } | ||
|
||
protected: | ||
const unsigned char *_test_kernel_model_circle; | ||
}; | ||
|
||
} // namespace test_kernel | ||
} // namespace luci_interpreter | ||
|
||
#endif // LUCI_INTERPRETER_TEST_MODELS_NEG_FLOOR_KERNEL_H |
60 changes: 60 additions & 0 deletions
60
onert-micro/luci-interpreter/include/luci_interpreter/test_models/floor/TestDataFloorBase.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,60 @@ | ||
/* | ||
* Copyright (c) 2023 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 LUCI_INTERPRETER_TEST_MODELS_FLOOR_KERNEL_BASE_H | ||
#define LUCI_INTERPRETER_TEST_MODELS_FLOOR_KERNEL_BASE_H | ||
|
||
#include "luci_interpreter/test_models/TestDataBase.h" | ||
|
||
namespace luci_interpreter | ||
{ | ||
namespace test_kernel | ||
{ | ||
|
||
template <typename T> class TestDataFloorBase : public TestDataBase<T> | ||
{ | ||
public: | ||
TestDataFloorBase() = default; | ||
|
||
const unsigned char *get_model_ptr() override final { return _test_kernel_model_circle; } | ||
|
||
const std::vector<T> &get_input_data_by_index(int i) override final | ||
{ | ||
switch (i) | ||
{ | ||
case 0: | ||
return _input_data; | ||
default: | ||
assert(false && "Wrong input index"); | ||
} | ||
} | ||
|
||
const std::vector<T> &get_output_data_by_index(int i) override final | ||
{ | ||
assert(i == 0); | ||
return _reference_output_data; | ||
} | ||
|
||
protected: | ||
std::vector<T> _input_data; | ||
std::vector<T> _reference_output_data; | ||
const unsigned char *_test_kernel_model_circle; | ||
}; | ||
|
||
} // namespace test_kernel | ||
} // namespace luci_interpreter | ||
|
||
#endif // LUCI_INTERPRETER_TEST_MODELS_FLOOR_KERNEL_BASE_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,47 @@ | ||
/* | ||
* Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* Copyright 2017 The TensorFlow Authors. 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 LUCI_INTERPRETER_PAL_FLOOR_COMMON_H | ||
#define LUCI_INTERPRETER_PAL_FLOOR_COMMON_H | ||
|
||
#include <cmath> | ||
|
||
namespace luci_interpreter_pal | ||
{ | ||
inline void Floor(const luci_interpreter::RuntimeShape &input_shape, const float *input_data, | ||
const luci_interpreter::RuntimeShape &output_shape, float *output_data) | ||
{ | ||
// check that input and output dimensions are equal | ||
int N = input_shape.dimensionsCount(); | ||
assert(N == output_shape.dimensionsCount()); | ||
|
||
// check that sizes of all dimensions are equal | ||
for (int i = 0; i < N; ++i) | ||
{ | ||
assert(input_shape.dims(i) == output_shape.dims(i)); | ||
} | ||
|
||
const int flat_size = input_shape.flatSize(); | ||
for (int i = 0; i < flat_size; i++) | ||
{ | ||
int offset = i; | ||
output_data[offset] = std::floor(input_data[offset]); | ||
} | ||
} | ||
} // namespace luci_interpreter_pal | ||
|
||
#endif // LUCI_INTERPRETER_PAL_FLOOR_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
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,27 @@ | ||
/* | ||
* Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* Copyright 2017 The TensorFlow Authors. 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 LUCI_INTERPRETER_PAL_FLOOR_H | ||
#define LUCI_INTERPRETER_PAL_FLOOR_H | ||
|
||
#include "PALFloorCommon.h" | ||
|
||
namespace luci_interpreter_pal | ||
{ | ||
} // namespace luci_interpreter_pal | ||
|
||
#endif // LUCI_INTERPRETER_PAL_FLOOR_H |
Oops, something went wrong.