From cf3944c3975455afd41d5f9f954b4d83b81a434d Mon Sep 17 00:00:00 2001 From: Chunseok Lee Date: Mon, 19 Aug 2024 11:59:17 +0900 Subject: [PATCH] [onert-mico] S8 test for Unpack - S8 Test for unpack added DCO-1.0-Signed-off-by: Chunseok Lee --- .../test_models/unpack/S8UnpackKernel.h | 107 ++++++++++++++++++ .../src/execute/kernels/Unpack.cpp | 7 ++ .../src/execute/kernels/tests/Unpack.test.cpp | 9 ++ 3 files changed, 123 insertions(+) create mode 100644 onert-micro/onert-micro/include/test_models/unpack/S8UnpackKernel.h diff --git a/onert-micro/onert-micro/include/test_models/unpack/S8UnpackKernel.h b/onert-micro/onert-micro/include/test_models/unpack/S8UnpackKernel.h new file mode 100644 index 00000000000..ad039655f0b --- /dev/null +++ b/onert-micro/onert-micro/include/test_models/unpack/S8UnpackKernel.h @@ -0,0 +1,107 @@ +/* + * 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_TEST_MODELS_S8_UNPACK_KERNEL_H +#define ONERT_MICRO_TEST_MODELS_S8_UNPACK_KERNEL_H + +#include "TestDataUnpackBase.h" + +namespace onert_micro +{ +namespace test_model +{ +namespace unpack_s8 +{ +/* + * Unpack Kernel: + * + * Input(2, 2, 2) + * | + * Unpack(num=2, axis=0) + * / \ + * Output1(2, 2, 2) Output1(2, 2, 2) + */ +const unsigned char test_kernel_model_circle[] = { + 0x1c, 0x00, 0x00, 0x00, 0x43, 0x49, 0x52, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, + 0x00, 0x14, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x10, 0x00, 0x04, 0x00, 0x0e, 0x00, + 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0x00, 0x4c, + 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xf4, 0xff, 0xff, 0xff, 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, 0x68, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x16, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x0c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x14, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xe8, 0x00, 0x00, + 0x00, 0x70, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x32, 0xff, 0xff, 0xff, 0x14, 0x00, + 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x48, + 0x00, 0x00, 0x00, 0x24, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x05, + 0x00, 0x00, 0x00, 0x6f, 0x66, 0x6d, 0x3a, 0x31, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x9a, 0xff, 0xff, 0xff, 0x14, 0x00, 0x00, + 0x00, 0x48, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x44, 0x00, + 0x00, 0x00, 0x8c, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfe, 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x03, 0x00, + 0x00, 0x00, 0x6f, 0x66, 0x6d, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, + 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, 0x54, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x50, 0x00, 0x00, 0x00, 0x0c, 0x00, + 0x14, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x2c, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x42, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x03, 0x00, 0x00, 0x00, 0x69, 0x66, 0x6d, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 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, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x58, 0x11, 0x00, 0x00, 0x00, 0x4f, 0x4e, 0x45, 0x2d, 0x74, 0x66, 0x6c, 0x69, 0x74, + 0x65, 0x32, 0x63, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x00, 0x00, 0x00 + +}; +const std::vector input_data = {1, 2, 3, 4, 5, 6, 7, 8}; +const std::vector reference_output_data_1 = {1, 2, 3, 4}; +const std::vector reference_output_data_2 = {5, 6, 7, 8}; + +} // namespace unpack_s8 + +class TestDataS8Unpack : public TestDataUnpackBase +{ +public: + TestDataS8Unpack() + { + _input_data = unpack_s8::input_data; + _reference_output_data_1 = unpack_s8::reference_output_data_1; + _reference_output_data_2 = unpack_s8::reference_output_data_2; + _test_kernel_model_circle = unpack_s8::test_kernel_model_circle; + } + + ~TestDataS8Unpack() override = default; +}; + +} // namespace test_model +} // namespace onert_micro + +#endif // ONERT_MICRO_TEST_MODELS_S8_UNPACK_KERNEL_H diff --git a/onert-micro/onert-micro/src/execute/kernels/Unpack.cpp b/onert-micro/onert-micro/src/execute/kernels/Unpack.cpp index cfa61f4b537..ecb0b01e721 100644 --- a/onert-micro/onert-micro/src/execute/kernels/Unpack.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/Unpack.cpp @@ -93,6 +93,13 @@ OMStatus onert_micro::execute::execute_kernel_CircleUnpack(const OMExecuteArgs & output_shape, axis_value); break; #endif // DIS_FLOAT +#ifndef DIS_QUANT + case circle::TensorType_INT8: + status = + pal::Unpack(params, input_shape, core::utils::castInputData(input_data), + output_shape, axis_value); + break; +#endif // DIS_QUANT default: { status = UnsupportedActivation; diff --git a/onert-micro/onert-micro/src/execute/kernels/tests/Unpack.test.cpp b/onert-micro/onert-micro/src/execute/kernels/tests/Unpack.test.cpp index 9c5738842a5..d0c76113ce5 100644 --- a/onert-micro/onert-micro/src/execute/kernels/tests/Unpack.test.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/tests/Unpack.test.cpp @@ -16,6 +16,7 @@ #include "execute/OMTestUtils.h" #include "test_models/unpack/FloatUnpackKernel.h" +#include "test_models/unpack/S8UnpackKernel.h" #include "test_models/unpack/NegUnpackKernel.h" namespace onert_micro @@ -40,6 +41,14 @@ TEST_F(UnpackTest, Float_P) EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0)); } +TEST_F(UnpackTest, S8_P) +{ + onert_micro::test_model::TestDataS8Unpack test_data_kernel; + std::vector output_data_vector = + onert_micro::execute::testing::checkKernel(1, &test_data_kernel); + EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0)); +} + TEST_F(UnpackTest, Input_output_type_mismatch_NEG) { onert_micro::test_model::NegTestDataInputOutputTypeMismatchUnpackKernel test_data_kernel;