From a7188e0555e923e27b7bbd103976dd9b5f38a4f5 Mon Sep 17 00:00:00 2001 From: Artem Balyshev Date: Thu, 5 Oct 2023 14:46:58 +0300 Subject: [PATCH] [onert-micro] Add float ResizeNearestNeighbor kernels This commit adds float ResizeNearestNeighbor kernels for onert-micro. ONE-DCO-1.0-Signed-off-by: Artem Balyshev --- .../FloatResizeNearestNeighborKernel.h | 364 ++++++++++++++++++ .../NegResizeNearestNeighborKernel.h | 92 +++++ .../TestDataResizeNearestNeighborBase.h | 60 +++ .../pal/cmsisnn/KernelsToBuild.lst | 1 + .../pal/common/PALResizeNearestNeighbor.h | 94 +++++ .../luci-interpreter/pal/common/Params.h | 6 + .../pal/mcu/KernelsToBuild.lst | 1 + .../src/kernels/ResizeBilinear.h | 45 --- .../src/kernels/ResizeNearestNeighbor.cpp | 80 ++-- .../src/kernels/ResizeNearestNeighbor.h | 45 --- .../kernels/ResizeNearestNeighbor.test.cpp | 227 ++--------- 11 files changed, 703 insertions(+), 312 deletions(-) create mode 100644 onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/FloatResizeNearestNeighborKernel.h create mode 100644 onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/NegResizeNearestNeighborKernel.h create mode 100644 onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/TestDataResizeNearestNeighborBase.h create mode 100644 onert-micro/luci-interpreter/pal/common/PALResizeNearestNeighbor.h delete mode 100644 onert-micro/luci-interpreter/src/kernels/ResizeBilinear.h delete mode 100644 onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.h diff --git a/onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/FloatResizeNearestNeighborKernel.h b/onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/FloatResizeNearestNeighborKernel.h new file mode 100644 index 00000000000..9b4e7d251a6 --- /dev/null +++ b/onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/FloatResizeNearestNeighborKernel.h @@ -0,0 +1,364 @@ +/* + * 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_RESIZE_NEAREST_NEIGHBOR_KERNEL_H +#define LUCI_INTERPRETER_TEST_MODELS_FLOAT_RESIZE_NEAREST_NEIGHBOR_KERNEL_H + +#include "TestDataResizeNearestNeighborBase.h" + +namespace luci_interpreter +{ +namespace test_kernel +{ +namespace resize_nearest_neighbor_float +{ +/* + * ResizeNearestNeighbor Kernel: + * + * Input(1, 4, 4, 8) + * | + * ResizeNearestNeighbor + * | + * Output(1, 16, 16, 8) + */ +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, + 0x4c, 0x00, 0x00, 0x00, 0x8c, 0x01, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 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, + 0x68, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x70, 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, 0x4a, 0x14, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa0, 0xff, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6f, 0x66, 0x6d, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x73, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x02, 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, 0x04, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 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, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, + 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 = { + 10.298298, -65.56192, -65.48421, -51.370033, -37.358875, 68.09911, -28.049213, -74.103264, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -97.28447, 72.05543, 76.05356, 95.023445, -27.921726, -11.455247, 31.07193, -65.78694, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 50.312668, -46.917915, 31.022425, -30.1396, 12.878587, 65.19479, 13.271307, -80.23689, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -0.69525874, 41.214996, 18.559265, 16.980064, 4.0301347, -28.414703, -59.516068, 62.129013}; + +const std::vector reference_output_data = { + 10.298298, -65.56192, -65.48421, -51.370033, -37.358875, 68.09911, -28.049213, -74.103264, + 10.298298, -65.56192, -65.48421, -51.370033, -37.358875, 68.09911, -28.049213, -74.103264, + 10.298298, -65.56192, -65.48421, -51.370033, -37.358875, 68.09911, -28.049213, -74.103264, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -97.28447, 72.05543, 76.05356, 95.023445, -27.921726, -11.455247, 31.07193, -65.78694, + -97.28447, 72.05543, 76.05356, 95.023445, -27.921726, -11.455247, 31.07193, -65.78694, + -97.28447, 72.05543, 76.05356, 95.023445, -27.921726, -11.455247, 31.07193, -65.78694, + 10.298298, -65.56192, -65.48421, -51.370033, -37.358875, 68.09911, -28.049213, -74.103264, + 10.298298, -65.56192, -65.48421, -51.370033, -37.358875, 68.09911, -28.049213, -74.103264, + 10.298298, -65.56192, -65.48421, -51.370033, -37.358875, 68.09911, -28.049213, -74.103264, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -97.28447, 72.05543, 76.05356, 95.023445, -27.921726, -11.455247, 31.07193, -65.78694, + -97.28447, 72.05543, 76.05356, 95.023445, -27.921726, -11.455247, 31.07193, -65.78694, + -97.28447, 72.05543, 76.05356, 95.023445, -27.921726, -11.455247, 31.07193, -65.78694, + 10.298298, -65.56192, -65.48421, -51.370033, -37.358875, 68.09911, -28.049213, -74.103264, + 10.298298, -65.56192, -65.48421, -51.370033, -37.358875, 68.09911, -28.049213, -74.103264, + 10.298298, -65.56192, -65.48421, -51.370033, -37.358875, 68.09911, -28.049213, -74.103264, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + 54.290348, -39.651768, 96.38616, 98.89169, -55.091187, -83.808556, -83.01185, -28.333675, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -50.724545, 3.110519, 21.322432, 9.211258, 25.231798, 46.919487, 99.83142, 55.398502, + -97.28447, 72.05543, 76.05356, 95.023445, -27.921726, -11.455247, 31.07193, -65.78694, + -97.28447, 72.05543, 76.05356, 95.023445, -27.921726, -11.455247, 31.07193, -65.78694, + -97.28447, 72.05543, 76.05356, 95.023445, -27.921726, -11.455247, 31.07193, -65.78694, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + -25.030579, 48.61087, -4.1321445, 75.28256, -68.740875, 1.433968, 88.15704, -6.77664, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 29.764292, 22.71885, -92.61434, 84.98954, 51.975292, -39.413055, 7.8604083, 63.997437, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 17.589115, -59.45725, 83.951096, -39.29275, 20.051659, 8.571633, -41.56029, -23.022821, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 29.8412, 2.6516876, -47.806282, 69.98114, -79.093735, -28.039436, -53.41087, 2.8676255, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + 21.599058, 55.24438, 28.319221, -96.02833, 48.20593, -37.2331, -51.708584, -51.362064, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + -60.841843, -6.8476315, -93.64622, 90.07673, 9.962581, 79.38798, -75.8042, -57.65992, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 90.61799, -93.56624, 2.743451, -22.862207, -66.0843, 7.904722, 29.070421, -13.117169, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 46.179005, -46.155643, -65.15945, -3.1775346, 0.5456849, -96.185036, -63.52502, -75.50465, + 50.312668, -46.917915, 31.022425, -30.1396, 12.878587, 65.19479, 13.271307, -80.23689, + 50.312668, -46.917915, 31.022425, -30.1396, 12.878587, 65.19479, 13.271307, -80.23689, + 50.312668, -46.917915, 31.022425, -30.1396, 12.878587, 65.19479, 13.271307, -80.23689, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -0.69525874, 41.214996, 18.559265, 16.980064, 4.0301347, -28.414703, -59.516068, 62.129013, + -0.69525874, 41.214996, 18.559265, 16.980064, 4.0301347, -28.414703, -59.516068, 62.129013, + -0.69525874, 41.214996, 18.559265, 16.980064, 4.0301347, -28.414703, -59.516068, 62.129013, + 50.312668, -46.917915, 31.022425, -30.1396, 12.878587, 65.19479, 13.271307, -80.23689, + 50.312668, -46.917915, 31.022425, -30.1396, 12.878587, 65.19479, 13.271307, -80.23689, + 50.312668, -46.917915, 31.022425, -30.1396, 12.878587, 65.19479, 13.271307, -80.23689, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -0.69525874, 41.214996, 18.559265, 16.980064, 4.0301347, -28.414703, -59.516068, 62.129013, + -0.69525874, 41.214996, 18.559265, 16.980064, 4.0301347, -28.414703, -59.516068, 62.129013, + -0.69525874, 41.214996, 18.559265, 16.980064, 4.0301347, -28.414703, -59.516068, 62.129013, + 50.312668, -46.917915, 31.022425, -30.1396, 12.878587, 65.19479, 13.271307, -80.23689, + 50.312668, -46.917915, 31.022425, -30.1396, 12.878587, 65.19479, 13.271307, -80.23689, + 50.312668, -46.917915, 31.022425, -30.1396, 12.878587, 65.19479, 13.271307, -80.23689, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -55.38661, -46.709187, -1.5717866, -1.8434023, 61.15225, -19.636839, 28.600264, 69.90152, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -91.06497, -13.100779, -30.178743, -93.116486, 37.64633, -60.00845, 64.729324, -55.224663, + -0.69525874, 41.214996, 18.559265, 16.980064, 4.0301347, -28.414703, -59.516068, 62.129013, + -0.69525874, 41.214996, 18.559265, 16.980064, 4.0301347, -28.414703, -59.516068, 62.129013, + -0.69525874, 41.214996, 18.559265, 16.980064, 4.0301347, -28.414703, -59.516068, 62.129013}; + +} // namespace resize_nearest_neighbor_float + +class TestDataFloatResizeNearestNeighbor : public TestDataResizeNearestNeighborBase +{ +public: + TestDataFloatResizeNearestNeighbor() + { + _input_data = resize_nearest_neighbor_float::input_data; + _reference_output_data = resize_nearest_neighbor_float::reference_output_data; + _test_kernel_model_circle = resize_nearest_neighbor_float::test_kernel_model_circle; + } + + ~TestDataFloatResizeNearestNeighbor() override = default; +}; + +} // namespace test_kernel +} // namespace luci_interpreter + +#endif // LUCI_INTERPRETER_TEST_MODELS_FLOAT_RESIZE_NEAREST_NEIGHBOR_KERNEL_H diff --git a/onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/NegResizeNearestNeighborKernel.h b/onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/NegResizeNearestNeighborKernel.h new file mode 100644 index 00000000000..8f6f7b36ac1 --- /dev/null +++ b/onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/NegResizeNearestNeighborKernel.h @@ -0,0 +1,92 @@ +/* + * 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_RESIZE_NEAREST_NEIGHBOR_KERNEL_H +#define LUCI_INTERPRETER_TEST_MODELS_NEG_RESIZE_NEAREST_NEIGHBOR_KERNEL_H + +#include "luci_interpreter/test_models/TestDataBase.h" + +namespace luci_interpreter +{ +namespace test_kernel +{ +namespace neg_input_output_type_mismatch_resize_nearest_neighbor_kernel +{ +/* + * ResizeNearestNeighbor Kernel with input output type mismatch: + * + * Input(1, 4, 4, 8) - Float32 + * | + * ResizeNearestNeighbor + * | + * Output(1, 16, 16, 8) - Int32 + */ +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, + 0x4c, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0xac, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 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, + 0x68, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x70, 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, 0x4a, 0x14, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, + 0x44, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xd0, 0xff, 0xff, 0xff, 0x10, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x6f, 0x66, 0x6d, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0f, 0x00, + 0x08, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x73, 0x69, 0x7a, 0x65, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 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, + 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x08, 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, 0x61, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x61, 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_resize_nearest_neighbor_kernel + +class NegTestDataInputOutputTypeMismatchResizeNearestNeighborKernel : public NegTestDataBase +{ +public: + NegTestDataInputOutputTypeMismatchResizeNearestNeighborKernel() + { + _test_kernel_model_circle = + neg_input_output_type_mismatch_resize_nearest_neighbor_kernel::test_kernel_model_circle; + } + + ~NegTestDataInputOutputTypeMismatchResizeNearestNeighborKernel() 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_RESIZE_NEAREST_NEIGHBOR_KERNEL_H diff --git a/onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/TestDataResizeNearestNeighborBase.h b/onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/TestDataResizeNearestNeighborBase.h new file mode 100644 index 00000000000..4eea7a18565 --- /dev/null +++ b/onert-micro/luci-interpreter/include/luci_interpreter/test_models/resize_nearest_neighbor/TestDataResizeNearestNeighborBase.h @@ -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_RESIZE_NEAREST_NEIGHBOR_KERNEL_BASE_H +#define LUCI_INTERPRETER_TEST_MODELS_RESIZE_NEAREST_NEIGHBOR_KERNEL_BASE_H + +#include "luci_interpreter/test_models/TestDataBase.h" + +namespace luci_interpreter +{ +namespace test_kernel +{ + +template class TestDataResizeNearestNeighborBase : public TestDataBase +{ +public: + TestDataResizeNearestNeighborBase() = default; + + const unsigned char *get_model_ptr() override final { return _test_kernel_model_circle; } + + const std::vector &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 &get_output_data_by_index(int i) override final + { + assert(i == 0); + return _reference_output_data; + } + +protected: + std::vector _input_data; + std::vector _reference_output_data; + const unsigned char *_test_kernel_model_circle; +}; + +} // namespace test_kernel +} // namespace luci_interpreter + +#endif // LUCI_INTERPRETER_TEST_MODELS_RESIZE_NEAREST_NEIGHBOR_KERNEL_BASE_H diff --git a/onert-micro/luci-interpreter/pal/cmsisnn/KernelsToBuild.lst b/onert-micro/luci-interpreter/pal/cmsisnn/KernelsToBuild.lst index 1f1c609b2e1..f3aab433c19 100644 --- a/onert-micro/luci-interpreter/pal/cmsisnn/KernelsToBuild.lst +++ b/onert-micro/luci-interpreter/pal/cmsisnn/KernelsToBuild.lst @@ -64,6 +64,7 @@ REGISTER_KERNEL(SUM, Sum) REGISTER_KERNEL(SELECT_V2, SelectV2) REGISTER_KERNEL(WHILE, While) REGISTER_KERNEL(RESIZE_BILINEAR, ResizeBilinear) +REGISTER_KERNEL(RESIZE_NEAREST_NEIGHBOR, ResizeNearestNeighbor) REGISTER_KERNEL(RSQRT, Rsqrt) REGISTER_KERNEL(NEG, Neg) REGISTER_KERNEL(ZEROS_LIKE, ZerosLike) diff --git a/onert-micro/luci-interpreter/pal/common/PALResizeNearestNeighbor.h b/onert-micro/luci-interpreter/pal/common/PALResizeNearestNeighbor.h new file mode 100644 index 00000000000..28959a296db --- /dev/null +++ b/onert-micro/luci-interpreter/pal/common/PALResizeNearestNeighbor.h @@ -0,0 +1,94 @@ +/* + * 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_PAL_RESIZE_NEAREST_NEIGHBOR_COMMON_H +#define LUCI_INTERPRETER_PAL_RESIZE_NEAREST_NEIGHBOR_COMMON_H + +#include "Params.h" +#include "PALUtils.h" + +namespace luci_interpreter_pal +{ + +inline int32_t getNearestNeighbor(const int input_value, const int32_t input_size, + const int32_t output_size, const bool align_corners, + const bool half_pixel_centers) +{ + const float scale = (align_corners && output_size > 1) + ? (input_size - 1) / static_cast(output_size - 1) + : input_size / static_cast(output_size); + const float offset = half_pixel_centers ? 0.5f : 0.0f; + int32_t output_value = + std::min(align_corners ? static_cast(std::round((input_value + offset) * scale)) + : static_cast(std::floor((input_value + offset) * scale)), + input_size - 1); + if (half_pixel_centers) + { + output_value = std::max(static_cast(0), output_value); + } + return output_value; +} + +template +inline void +ResizeNearestNeighbor(const ResizeNearestNeighborParams &op_params, + const luci_interpreter::RuntimeShape &unextended_input_shape, + const T *input_data, const luci_interpreter::RuntimeShape &output_size_shape, + const int32_t *output_size_data, + const luci_interpreter::RuntimeShape &unextended_output_shape, T *output_data) +{ + const luci_interpreter::RuntimeShape input_shape = + luci_interpreter::RuntimeShape::extendedShape(4, unextended_input_shape); + const luci_interpreter::RuntimeShape output_shape = + luci_interpreter::RuntimeShape::extendedShape(4, unextended_output_shape); + + int32_t batches = MatchingDim(input_shape, 0, output_shape, 0); + int32_t input_height = input_shape.dims(1); + int32_t input_width = input_shape.dims(2); + int32_t depth = MatchingDim(input_shape, 3, output_shape, 3); + + int32_t output_height = output_size_data[0]; + int32_t output_width = output_size_data[1]; + + const int col_offset = input_shape.dims(3); + const int row_offset = input_shape.dims(2) * col_offset; + const int batch_offset = input_shape.dims(1) * row_offset; + + const T *input_ptr = input_data; + T *output_ptr = output_data; + for (int b = 0; b < batches; ++b) + { + for (int y = 0; y < output_height; ++y) + { + int32_t in_y = getNearestNeighbor(y, input_height, output_height, op_params.align_corners, + op_params.half_pixel_centers); + const T *y_input_ptr = input_ptr + in_y * row_offset; + for (int x = 0; x < output_width; ++x) + { + int32_t in_x = getNearestNeighbor(x, input_width, output_width, op_params.align_corners, + op_params.half_pixel_centers); + const T *x_input_ptr = y_input_ptr + in_x * col_offset; + memcpy(output_ptr, x_input_ptr, depth * sizeof(T)); + output_ptr += depth; + } + } + input_ptr += batch_offset; + } +} + +} // namespace luci_interpreter_pal + +#endif // LUCI_INTERPRETER_PAL_RESIZE_NEAREST_NEIGHBOR_COMMON_H diff --git a/onert-micro/luci-interpreter/pal/common/Params.h b/onert-micro/luci-interpreter/pal/common/Params.h index a6b8e46bb45..bb4bf3d5e2c 100644 --- a/onert-micro/luci-interpreter/pal/common/Params.h +++ b/onert-micro/luci-interpreter/pal/common/Params.h @@ -27,6 +27,12 @@ struct MeanParams int16_t axis[4]; }; +struct ResizeNearestNeighborParams +{ + bool align_corners; + bool half_pixel_centers; +}; + struct PadParams { int8_t left_padding_count; diff --git a/onert-micro/luci-interpreter/pal/mcu/KernelsToBuild.lst b/onert-micro/luci-interpreter/pal/mcu/KernelsToBuild.lst index 2ab702fefa1..bc5685630af 100644 --- a/onert-micro/luci-interpreter/pal/mcu/KernelsToBuild.lst +++ b/onert-micro/luci-interpreter/pal/mcu/KernelsToBuild.lst @@ -78,6 +78,7 @@ REGISTER_KERNEL(SELECT_V2, SelectV2) REGISTER_KERNEL(WHILE, While) REGISTER_KERNEL(UNIDIRECTIONAL_SEQUENCE_LSTM, UnidirectionalSequenceLSTM) REGISTER_KERNEL(RESIZE_BILINEAR, ResizeBilinear) +REGISTER_KERNEL(RESIZE_NEAREST_NEIGHBOR, ResizeNearestNeighbor) REGISTER_KERNEL(RSQRT, Rsqrt) REGISTER_KERNEL(NEG, Neg) REGISTER_KERNEL(ZEROS_LIKE, ZerosLike) diff --git a/onert-micro/luci-interpreter/src/kernels/ResizeBilinear.h b/onert-micro/luci-interpreter/src/kernels/ResizeBilinear.h deleted file mode 100644 index b7bdc2ab772..00000000000 --- a/onert-micro/luci-interpreter/src/kernels/ResizeBilinear.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 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_KERNELS_RESIZEBILINEAR_H -#define LUCI_INTERPRETER_KERNELS_RESIZEBILINEAR_H - -#include "core/Kernel.h" -#include "core/KernelParams.h" - -namespace luci_interpreter -{ -namespace kernels -{ - -class ResizeBilinear : public KernelWithParams -{ -public: - ResizeBilinear(const Tensor *input, const Tensor *shape, Tensor *output, - const ResizeBilinearParams ¶ms); - - const Tensor *input() const { return _inputs[0]; } - const Tensor *size() const { return _inputs[1]; } - Tensor *output() const { return _outputs[0]; } - - void configure() override; - void execute() const override; -}; - -} // namespace kernels -} // namespace luci_interpreter - -#endif // LUCI_INTERPRETER_KERNELS_RESIZEBILINEAR_H diff --git a/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.cpp b/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.cpp index 57ca4d53591..2faea49481a 100644 --- a/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.cpp +++ b/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * Copyright 2019 The TensorFlow Authors. All Rights Reserved. + * Copyright 2023 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. @@ -15,61 +15,67 @@ * limitations under the License. */ -#include "kernels/ResizeNearestNeighbor.h" - +#include "Builders.h" #include "kernels/Utils.h" +#include "TISOKernel.h" -#include #include "PALResizeNearestNeighbor.h" namespace luci_interpreter { -namespace kernels -{ -ResizeNearestNeighbor::ResizeNearestNeighbor(const Tensor *input, const Tensor *size, - Tensor *output, - const ResizeNearestNeighborParams ¶ms) - : KernelWithParams({input, size}, {output}, params) +void configure_kernel_CircleResizeNearestNeighbor(const circle::Operator *cur_op, + BaseRuntimeGraph *runtime_graph) { -} + // Check of the size of input. Should be 2 + LUCI_INTERPRETER_CHECK(cur_op->inputs()->size() == 2); + const kernels::TISOKernel tiso_kernel(cur_op, runtime_graph); -void ResizeNearestNeighbor::configure() -{ - LUCI_INTERPRETER_CHECK(input()->shape().num_dims() == 4); - LUCI_INTERPRETER_CHECK(size()->shape().num_dims() == 1); - LUCI_INTERPRETER_CHECK(size()->element_type() == DataType::S32); - LUCI_INTERPRETER_CHECK(size()->shape().dim(0) == 2); - Shape output_shape(4); - output_shape.dim(0) = input()->shape().dim(0); - output_shape.dim(1) = getTensorData(size())[0]; - output_shape.dim(2) = getTensorData(size())[1]; - output_shape.dim(3) = input()->shape().dim(3); - // TODO: enable it only if kernel with dynamic shapes - output()->resize(output_shape); + LUCI_INTERPRETER_CHECK(Tensor::element_type(tiso_kernel.input1()) == + Tensor::element_type(tiso_kernel.output())); + LUCI_INTERPRETER_CHECK(Tensor::num_dims(tiso_kernel.input1()) == 4); + LUCI_INTERPRETER_CHECK(Tensor::num_dims(tiso_kernel.input2()) == 1); + LUCI_INTERPRETER_CHECK(Tensor::element_type(tiso_kernel.input2()) == DataType::S32); + LUCI_INTERPRETER_CHECK(Tensor::dim(tiso_kernel.input2(), 0) == 2); + + const auto *params = cur_op->builtin_options_as_ResizeNearestNeighborOptions(); + if (params->half_pixel_centers() && params->align_corners()) + assert(false && "If half_pixel_centers is True, align_corners must be False."); } -void ResizeNearestNeighbor::execute() const +void execute_kernel_CircleResizeNearestNeighbor(const circle::Operator *cur_op, + BaseRuntimeGraph *runtime_graph) { - tflite::ResizeNearestNeighborParams op_params{}; - op_params.align_corners = params().align_corners; - op_params.half_pixel_centers = params().half_pixel_centers; - switch (output()->element_type()) + kernels::TISOKernel tiso_kernel(cur_op, runtime_graph); + kernels::TISOData tiso_data = tiso_kernel.readData(); + + // Get parameters + const auto *op_params = cur_op->builtin_options_as_ResizeNearestNeighborOptions(); + + luci_interpreter_pal::ResizeNearestNeighborParams params; + params.align_corners = op_params->align_corners(); + params.half_pixel_centers = false; + + const uint8_t *input_data = runtime_graph->getDataByTensor(tiso_kernel.input1()); + const uint8_t *size_data = runtime_graph->getConstDataByTensor(tiso_kernel.input2()); + uint8_t *output_data = runtime_graph->getDataByTensor(tiso_kernel.output()); + + switch (Tensor::element_type(tiso_kernel.output())) { +#ifndef DIS_FLOAT case DataType::FLOAT32: - tflite::reference_ops::ResizeNearestNeighbor( - op_params, getTensorShape(input()), getTensorData(input()), getTensorShape(size()), - getTensorData(size()), getTensorShape(output()), getTensorData(output())); - break; - case DataType::U8: luci_interpreter_pal::ResizeNearestNeighbor( - op_params, getTensorShape(input()), getTensorData(input()), getTensorShape(size()), - getTensorData(size()), getTensorShape(output()), getTensorData(output())); + params, kernels::getTensorRuntimeShape(tiso_kernel.input1(), runtime_graph), + kernels::getTensorData(input_data), + kernels::getTensorRuntimeShape(tiso_kernel.input2(), runtime_graph), + kernels::getTensorData(size_data), + kernels::getTensorRuntimeShape(tiso_kernel.output(), runtime_graph), + kernels::getTensorData(output_data)); break; +#endif // DIS_FLOAT default: assert(false && "Unsupported type."); } } -} // namespace kernels } // namespace luci_interpreter diff --git a/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.h b/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.h deleted file mode 100644 index 137d031cf44..00000000000 --- a/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 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_KERNELS_RESIZENEARESTNEIGHBOR_H -#define LUCI_INTERPRETER_KERNELS_RESIZENEARESTNEIGHBOR_H - -#include "core/Kernel.h" -#include "core/KernelParams.h" - -namespace luci_interpreter -{ -namespace kernels -{ - -class ResizeNearestNeighbor : public KernelWithParams -{ -public: - ResizeNearestNeighbor(const Tensor *input, const Tensor *shape, Tensor *output, - const ResizeNearestNeighborParams ¶ms); - - const Tensor *input() const { return _inputs[0]; } - const Tensor *size() const { return _inputs[1]; } - Tensor *output() const { return _outputs[0]; } - - void configure() override; - void execute() const override; -}; - -} // namespace kernels -} // namespace luci_interpreter - -#endif // LUCI_INTERPRETER_KERNELS_RESIZENEARESTNEIGHBOR_H diff --git a/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.test.cpp b/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.test.cpp index 7ade02a6fee..44aa97e0f46 100644 --- a/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.test.cpp +++ b/onert-micro/luci-interpreter/src/kernels/ResizeNearestNeighbor.test.cpp @@ -15,217 +15,74 @@ * limitations under the License. */ -#include "kernels/ResizeNearestNeighbor.h" #include "kernels/TestUtils.h" -#include "luci_interpreter/TestMemoryManager.h" +#include "luci_interpreter/test_models/resize_nearest_neighbor/FloatResizeNearestNeighborKernel.h" +#include "luci_interpreter/test_models/resize_nearest_neighbor/NegResizeNearestNeighborKernel.h" + +#include "loader/ModuleLoader.h" namespace luci_interpreter { -namespace kernels -{ namespace { using namespace testing; -template -void Check(std::initializer_list input_shape, std::initializer_list size_shape, - std::initializer_list output_shape, std::initializer_list input_data, - std::initializer_list size_data, std::initializer_list output_data, - bool align_corners, bool half_pixel_centers) -{ - std::unique_ptr memory_manager = std::make_unique(); - - Tensor input_tensor = - makeInputTensor(input_shape, input_data, memory_manager.get()); - Tensor size_tensor = makeInputTensor(size_shape, size_data, memory_manager.get()); - Tensor output_tensor = makeOutputTensor(DataType::FLOAT32); - - ResizeNearestNeighborParams params{}; - params.align_corners = align_corners; - params.half_pixel_centers = half_pixel_centers; - - ResizeNearestNeighbor kernel(&input_tensor, &size_tensor, &output_tensor, params); - kernel.configure(); - memory_manager->allocate_memory(output_tensor); - kernel.execute(); - - EXPECT_THAT(extractTensorShape(output_tensor), ::testing::ElementsAreArray(output_shape)); - EXPECT_THAT(extractTensorData(output_tensor), FloatArrayNear(output_data)); -} - -template <> -void Check(std::initializer_list input_shape, - std::initializer_list size_shape, - std::initializer_list output_shape, - std::initializer_list input_data, - std::initializer_list size_data, - std::initializer_list output_data, bool align_corners, - bool half_pixel_centers) -{ - std::unique_ptr memory_manager = std::make_unique(); - - std::pair quant_param = - quantizationParams(std::min(input_data) < 0 ? std::min(input_data) : 0.f, - std::max(input_data) > 0 ? std::max(input_data) : 0.f); - Tensor input_tensor = makeInputTensor( - input_shape, quant_param.first, quant_param.second, input_data, memory_manager.get()); - Tensor size_tensor = makeInputTensor(size_shape, size_data, memory_manager.get()); - Tensor output_tensor = makeOutputTensor(DataType::U8, quant_param.first, quant_param.first); - - ResizeNearestNeighborParams params{}; - params.align_corners = align_corners; - params.half_pixel_centers = half_pixel_centers; - - ResizeNearestNeighbor kernel(&input_tensor, &size_tensor, &output_tensor, params); - kernel.configure(); - memory_manager->allocate_memory(output_tensor); - kernel.execute(); - - EXPECT_THAT(extractTensorShape(output_tensor), ::testing::ElementsAreArray(output_shape)); - EXPECT_THAT(dequantizeTensorData(output_tensor), - FloatArrayNear(output_data, output_tensor.scale())); -} - -template class ResizeNearestNeighborTest : public ::testing::Test +class ResizeNearestNeighborTest : public ::testing::Test { + // Do nothing }; -using DataTypes = ::testing::Types; -TYPED_TEST_SUITE(ResizeNearestNeighborTest, DataTypes); - -TYPED_TEST(ResizeNearestNeighborTest, SimpleTest) +template +std::vector checkResizeNearestNeighborKernel(test_kernel::TestDataBase *test_data_base) { - Check({2, 2, 2, 1}, {2}, {2, 3, 3, 1}, - { - 3, 6, // - 9, 12, // - 4, 10, // - 10, 16 // - }, - {3, 3}, - { - 3, 3, 6, // - 3, 3, 6, // - 9, 9, 12, // - 4, 4, 10, // - 4, 4, 10, // - 10, 10, 16, // - }, - false, false); -} + MemoryManager memory_manager{}; + RuntimeModule runtime_module{}; + bool dealloc_input = true; -TYPED_TEST(ResizeNearestNeighborTest, AlignCenterTest) -{ - Check({2, 2, 2, 1}, {2}, {2, 3, 3, 1}, - { - 3, 6, // - 9, 12, // - 4, 10, // - 10, 16 // - }, - {3, 3}, - { - 3, 6, 6, // - 9, 12, 12, // - 9, 12, 12, // - 4, 10, 10, // - 10, 16, 16, // - 10, 16, 16, // - }, - true, false); -} + // Load model with single op + auto *model_data_raw = reinterpret_cast(test_data_base->get_model_ptr()); + ModuleLoader::load(&runtime_module, &memory_manager, model_data_raw, dealloc_input); -TYPED_TEST(ResizeNearestNeighborTest, HalfPixelCenterTest) -{ - Check({2, 2, 2, 1}, {2}, {2, 3, 3, 1}, - { - 3, 6, // - 9, 12, // - 4, 10, // - 10, 16 // - }, - {3, 3}, - { - 3, 6, 6, // - 9, 12, 12, // - 9, 12, 12, // - 4, 10, 10, // - 10, 16, 16, // - 10, 16, 16, // - }, - false, true); -} + auto *main_runtime_graph = runtime_module.getMainGraph(); + assert(main_runtime_graph->getNumOfInputTensors() == 1); -TEST(ResizeNearestNeighborTest, InputShapeInvalid_NEG) -{ - std::unique_ptr memory_manager = std::make_unique(); + // Set input data + { + auto *input_tensor_data = reinterpret_cast(main_runtime_graph->configureGraphInput(0)); + std::copy(test_data_base->get_input_data_by_index(0).begin(), + test_data_base->get_input_data_by_index(0).end(), input_tensor_data); + } - Tensor input_tensor = makeInputTensor({2, 2, 2}, - { - 3, 6, // - 9, 12, // - 4, 10, // - 10, 16 // - }, - memory_manager.get()); - Tensor size_tensor = makeInputTensor({2}, {3, 3}, memory_manager.get()); - Tensor output_tensor = makeOutputTensor(DataType::FLOAT32); + runtime_module.execute(); - ResizeNearestNeighborParams params{}; - params.align_corners = false; - params.half_pixel_centers = false; + assert(main_runtime_graph->getNumOfOutputTensors() == 1); - ResizeNearestNeighbor kernel(&input_tensor, &size_tensor, &output_tensor, params); - EXPECT_ANY_THROW(kernel.configure()); + T *output_data = reinterpret_cast(main_runtime_graph->getOutputDataByIndex(0)); + const size_t num_elements = (main_runtime_graph->getOutputDataSizeByIndex(0) / sizeof(T)); + std::vector output_data_vector(output_data, output_data + num_elements); + return output_data_vector; } -TEST(ResizeNearestNeighborTest, SizeShapeInvalid_NEG) +TEST_F(ResizeNearestNeighborTest, Float_P) { - std::unique_ptr memory_manager = std::make_unique(); - - Tensor input_tensor = makeInputTensor({2, 2, 2, 1}, - { - 3, 6, // - 9, 12, // - 4, 10, // - 10, 16 // - }, - memory_manager.get()); - Tensor size_tensor = makeInputTensor({2, 1}, {3, 3}, memory_manager.get()); - Tensor output_tensor = makeOutputTensor(DataType::FLOAT32); - - ResizeNearestNeighborParams params{}; - params.align_corners = false; - params.half_pixel_centers = false; - - ResizeNearestNeighbor kernel(&input_tensor, &size_tensor, &output_tensor, params); - EXPECT_ANY_THROW(kernel.configure()); + test_kernel::TestDataFloatResizeNearestNeighbor test_data_kernel; + std::vector output_data_vector = checkResizeNearestNeighborKernel(&test_data_kernel); + EXPECT_THAT(output_data_vector, kernels::testing::FloatArrayNear( + test_data_kernel.get_output_data_by_index(0), 0.0001f)); } -TEST(ResizeNearestNeighborTest, SizeDimInvalid_NEG) +TEST_F(ResizeNearestNeighborTest, Input_output_type_mismatch_NEG) { - std::unique_ptr memory_manager = std::make_unique(); - - Tensor input_tensor = makeInputTensor({2, 2, 2, 1}, - { - 3, 6, // - 9, 12, // - 4, 10, // - 10, 16 // - }, - memory_manager.get()); - Tensor size_tensor = makeInputTensor({3}, {3, 3, 1}, memory_manager.get()); - Tensor output_tensor = makeOutputTensor(DataType::FLOAT32); - - ResizeNearestNeighborParams params{}; - params.align_corners = false; - params.half_pixel_centers = false; - - ResizeNearestNeighbor kernel(&input_tensor, &size_tensor, &output_tensor, params); - EXPECT_ANY_THROW(kernel.configure()); + test_kernel::NegTestDataInputOutputTypeMismatchResizeNearestNeighborKernel test_data_kernel; + MemoryManager memory_manager{}; + RuntimeModule runtime_module{}; + bool dealloc_input = true; + // Load model with single op + auto *model_data_raw = reinterpret_cast(test_data_kernel.get_model_ptr()); + EXPECT_DEATH(ModuleLoader::load(&runtime_module, &memory_manager, model_data_raw, dealloc_input), + ""); } } // namespace -} // namespace kernels } // namespace luci_interpreter