-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[onert-micro] Support L2Pool2D kernel (#13082)
This commit supports L2Pool2D kernel. ONE-DCO-1.0-Signed-off-by: Vyacheslav Bazhenov <[email protected]>
- Loading branch information
1 parent
ff75a4a
commit 1a1a52a
Showing
9 changed files
with
637 additions
and
1 deletion.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
onert-micro/onert-micro/include/pal/common/PALL2Pool2DCommon.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,91 @@ | ||
/* | ||
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* Copyright 2020 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 ONERT_MICRO_EXECUTE_PAL_L2_POOL_2D_COMMON_H | ||
#define ONERT_MICRO_EXECUTE_PAL_L2_POOL_2D_COMMON_H | ||
|
||
#include "PALUtils.h" | ||
|
||
#include "core/OMKernelData.h" | ||
#include "core/OMRuntimeShape.h" | ||
#include <cmath> | ||
namespace onert_micro | ||
{ | ||
namespace execute | ||
{ | ||
namespace pal | ||
{ | ||
// TODO: Reduce code duplication with other pools | ||
OMStatus L2Pool(const core::Pool2DParams ¶ms, const core::OMRuntimeShape &input_shape, | ||
const float *input_data, const core::OMRuntimeShape &output_shape, | ||
float *output_data) | ||
{ | ||
const int32_t batches = input_shape.dims(0); | ||
const int32_t depth = output_shape.dims(3); | ||
const int32_t input_height = input_shape.dims(1); | ||
const int32_t input_width = input_shape.dims(2); | ||
const int32_t output_height = output_shape.dims(1); | ||
const int32_t output_width = output_shape.dims(2); | ||
const int32_t stride_height = params.stride_h; | ||
const int32_t stride_width = params.stride_w; | ||
for (int batch = 0; batch < batches; ++batch) | ||
{ | ||
for (int out_y = 0; out_y < output_height; ++out_y) | ||
{ | ||
for (int out_x = 0; out_x < output_width; ++out_x) | ||
{ | ||
for (int channel = 0; channel < depth; ++channel) | ||
{ | ||
const int in_x_origin = (out_x * stride_width) - params.pad_w; | ||
const int in_y_origin = (out_y * stride_height) - params.pad_h; | ||
// Compute the boundaries of the filter region clamped so as to | ||
// ensure that the filter window fits in the input array. | ||
const int filter_x_start = std::max(0, -in_x_origin); | ||
const int filter_x_end = std::min(params.filter_w, input_width - in_x_origin); | ||
const int filter_y_start = std::max(0, -in_y_origin); | ||
const int filter_y_end = std::min(params.filter_h, input_height - in_y_origin); | ||
float sum_squares = 0.f; | ||
int filter_count = 0; | ||
for (int filter_y = filter_y_start; filter_y < filter_y_end; ++filter_y) | ||
{ | ||
for (int filter_x = filter_x_start; filter_x < filter_x_end; ++filter_x) | ||
{ | ||
const int in_x = in_x_origin + filter_x; | ||
const int in_y = in_y_origin + filter_y; | ||
const float val = | ||
input_data[offset(input_shape.dimsData(), batch, in_y, in_x, channel)]; | ||
sum_squares += val * val; | ||
filter_count++; | ||
} | ||
} | ||
assert(filter_count != 0); | ||
const float l2pool_result = std::sqrt(sum_squares / filter_count); | ||
output_data[offset(output_shape.dimsData(), batch, out_y, out_x, channel)] = | ||
activationFunctionWithMinMax(l2pool_result, params.activation_min, | ||
params.activation_max); | ||
} | ||
} | ||
} | ||
} | ||
return Ok; | ||
} | ||
|
||
} // namespace pal | ||
} // namespace execute | ||
} // namespace onert_micro | ||
|
||
#endif // ONERT_MICRO_EXECUTE_PAL_L2_POOL_2D_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,34 @@ | ||
/* | ||
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* Copyright 2020 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 ONERT_MICRO_EXECUTE_PAL_L2_POOL_2D_H | ||
#define ONERT_MICRO_EXECUTE_PAL_L2_POOL_2D_H | ||
|
||
#include "PALL2Pool2DCommon.h" | ||
|
||
namespace onert_micro | ||
{ | ||
namespace execute | ||
{ | ||
namespace pal | ||
{ | ||
|
||
} // namespace pal | ||
} // namespace execute | ||
} // namespace onert_micro | ||
|
||
#endif // ONERT_MICRO_EXECUTE_PAL_L2_POOL_2D_H |
101 changes: 101 additions & 0 deletions
101
onert-micro/onert-micro/include/test_models/l2pool2d/FloatL2Pool2DKernel.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,101 @@ | ||
/* | ||
* 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_FLOAT_L2POOL2D_KERNEL_H | ||
#define ONERT_MICRO_TEST_MODELS_FLOAT_L2POOL2D_KERNEL_H | ||
|
||
#include "TestDataL2Pool2DBase.h" | ||
|
||
namespace onert_micro | ||
{ | ||
namespace test_model | ||
{ | ||
namespace l2pool2d_float | ||
{ | ||
/* | ||
* L2Pool2D Kernel: | ||
* | ||
* Input(1, 8, 8, 1) | ||
* | | ||
* L2Pool2D | ||
* | | ||
* Output(1, 7, 7, 1) | ||
*/ | ||
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, 0x48, 0x01, 0x00, 0x00, 0x64, 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, | ||
0x7c, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 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, 0x05, 0x1c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, | ||
0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x17, 0x00, 0x10, 0x00, 0x0c, 0x00, | ||
0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 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, | ||
0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xd4, 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, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, | ||
0x01, 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, | ||
0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 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, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 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<float> input_data = { | ||
67.38262, 67.41811, 1.2834148, -98.304276, -79.165695, 15.270965, 3.746103, -54.763, | ||
-42.926304, -23.553911, -19.94737, 47.355026, 31.100943, 8.447245, -75.31512, -16.644464, | ||
22.489397, -39.29673, -98.54282, -85.136086, 41.03638, -37.152763, -79.57822, -68.96887, | ||
11.1106205, -10.539243, -8.441398, -52.19395, 6.378709, 9.458231, -77.18643, 99.294, | ||
76.699104, 45.281494, -19.284706, 65.62093, -66.792015, -1.4548094, -82.337814, -73.516815, | ||
5.0163054, 80.22257, 15.349068, 19.546398, 24.824991, 16.236868, 92.39976, 76.70845, | ||
-36.775307, -12.240916, 59.4311, 60.621857, 11.79261, -64.71309, -63.46639, -33.302174, | ||
-36.784237, -40.939827, 15.621524, -90.70094, 29.704996, -71.49415, 14.5302105, -17.651545}; | ||
const std::vector<float> reference_output_data = { | ||
53.57955, 37.07942, 55.465694, 69.174965, 43.413803, 38.700638, 47.33504, 33.34464, 55.244015, | ||
69.998634, 55.095154, 32.02708, 58.0016, 65.26638, 23.898365, 53.472546, 70.27501, 54.07641, | ||
28.25977, 58.65199, 82.015915, 45.18763, 25.517868, 43.224625, 53.693985, 33.887444, 56.632225, | ||
83.667915, 59.987476, 47.6801, 36.385647, 49.41058, 36.54862, 62.415905, 81.55694, 44.618065, | ||
50.875214, 44.228725, 34.68579, 36.07896, 65.22483, 69.9266, 33.657883, 37.423244, 62.605423, | ||
56.839954, 50.79529, 58.17711, 37.61556}; | ||
|
||
} // namespace l2pool2d_float | ||
|
||
class TestDataFloatL2Pool2D : public TestDataL2Pool2DBase<float> | ||
{ | ||
public: | ||
TestDataFloatL2Pool2D() | ||
{ | ||
_input_data = l2pool2d_float::input_data; | ||
_reference_output_data = l2pool2d_float::reference_output_data; | ||
_test_kernel_model_circle = l2pool2d_float::test_kernel_model_circle; | ||
} | ||
|
||
~TestDataFloatL2Pool2D() override = default; | ||
}; | ||
|
||
} // namespace test_model | ||
} // namespace onert_micro | ||
|
||
#endif // ONERT_MICRO_TEST_MODELS_FLOAT_L2POOL2D_KERNEL_H |
87 changes: 87 additions & 0 deletions
87
onert-micro/onert-micro/include/test_models/l2pool2d/NegL2Pool2DKernel.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,87 @@ | ||
/* | ||
* 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_NEG_L2POOL2D_KERNEL_H | ||
#define ONERT_MICRO_TEST_MODELS_NEG_L2POOL2D_KERNEL_H | ||
|
||
#include "TestDataL2Pool2DBase.h" | ||
|
||
namespace onert_micro | ||
{ | ||
namespace test_model | ||
{ | ||
namespace neg_l2pool2d_kernel | ||
{ | ||
/* | ||
* L2Pool2D Kernel with input output type mismatch: | ||
* | ||
* Input(1, 8, 8, 1) - Float32 | ||
* | | ||
* L2Pool2D | ||
* | | ||
* Output(1, 7, 7, 1) - 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, | ||
0x2c, 0x00, 0x00, 0x00, 0x58, 0x01, 0x00, 0x00, 0x74, 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, | ||
0x7c, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 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, 0x05, 0x1c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, | ||
0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x17, 0x00, 0x10, 0x00, 0x0c, 0x00, | ||
0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 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, | ||
0x50, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0f, 0x00, | ||
0x08, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 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, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, | ||
0x01, 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, | ||
0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 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, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 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_l2pool2d_kernel | ||
|
||
class NegTestDataInputOutputTypeMismatchL2Pool2DKernel : public NegTestDataBase | ||
{ | ||
public: | ||
NegTestDataInputOutputTypeMismatchL2Pool2DKernel() | ||
{ | ||
_test_kernel_model_circle = neg_l2pool2d_kernel::test_kernel_model_circle; | ||
} | ||
|
||
~NegTestDataInputOutputTypeMismatchL2Pool2DKernel() 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_model | ||
} // namespace onert_micro | ||
|
||
#endif // ONERT_MICRO_TEST_MODELS_NEG_L2POOL2D_KERNEL_H |
61 changes: 61 additions & 0 deletions
61
onert-micro/onert-micro/include/test_models/l2pool2d/TestDataL2Pool2DBase.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,61 @@ | ||
/* | ||
* 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_L2POOL2D_KERNEL_BASE_H | ||
#define ONERT_MICRO_TEST_MODELS_L2POOL2D_KERNEL_BASE_H | ||
|
||
#include "test_models/TestDataBase.h" | ||
#include <cassert> | ||
|
||
namespace onert_micro | ||
{ | ||
namespace test_model | ||
{ | ||
|
||
template <typename T> class TestDataL2Pool2DBase : public TestDataBase<T> | ||
{ | ||
public: | ||
TestDataL2Pool2DBase() = 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_model | ||
} // namespace onert_micro | ||
|
||
#endif // ONERT_MICRO_TEST_MODELS_L2POOL2D_KERNEL_BASE_H |
Oops, something went wrong.