-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[onert-micro] Add BroadcastTo op #13756
Open
BalyshevArtem
wants to merge
1
commit into
Samsung:master
Choose a base branch
from
BalyshevArtem:broadcast_to_onert_micro_2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
114 changes: 114 additions & 0 deletions
114
onert-micro/onert-micro/include/pal/common/PALBroadcastTo.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,114 @@ | ||
/* | ||
* 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_EXECUTE_PAL_BROADCAST_TO_COMMON_H | ||
#define ONERT_MICRO_EXECUTE_PAL_BROADCAST_TO_COMMON_H | ||
|
||
#include "core/OMRuntimeShape.h" | ||
#include "OMStatus.h" | ||
#include "PALUtils.h" | ||
#include "ProcessBroadcastShapes.h" | ||
#include <cmath> | ||
|
||
namespace onert_micro | ||
{ | ||
namespace execute | ||
{ | ||
namespace pal | ||
{ | ||
|
||
template <int N> | ||
void BroadcastImpl(const NdArrayDesc<N> &input_desc, const uint8_t *input_data, | ||
const NdArrayDesc<N> &output_desc, uint8_t *output_data, int indexes[N], int dim, | ||
const int last_broadcasting_dim, const uint32_t type_size) | ||
{ | ||
// Copy data from input to output. | ||
if (dim == last_broadcasting_dim) | ||
{ | ||
int copy_size = output_desc.strides[dim] * type_size; | ||
const uint8_t *data_src = input_data + subscriptToIndex(input_desc, indexes) * type_size; | ||
uint8_t *data_dst = output_data + subscriptToIndex(output_desc, indexes) * type_size; | ||
for (int i = 0; i < output_desc.extents[dim]; ++i, data_dst += copy_size) | ||
{ | ||
memcpy(data_dst, data_src, copy_size); | ||
} | ||
return; | ||
} | ||
|
||
// Recursive call to find the next broadcasting. | ||
for (indexes[dim] = 0; indexes[dim] < input_desc.extents[dim]; ++indexes[dim]) | ||
{ | ||
BroadcastImpl<N>(input_desc, input_data, output_desc, output_data, indexes, dim + 1, | ||
last_broadcasting_dim, type_size); | ||
} | ||
|
||
// Duplicate data in output tensor. | ||
indexes[dim] = 0; | ||
if (input_desc.extents[dim] != output_desc.extents[dim]) | ||
{ | ||
int copy_size = output_desc.strides[dim] * type_size; | ||
uint8_t *data_src = output_data + subscriptToIndex(output_desc, indexes) * type_size; | ||
uint8_t *data_dst = data_src + copy_size; | ||
for (int i = 1; i < output_desc.extents[dim]; ++i, data_dst += copy_size) | ||
{ | ||
memcpy(data_dst, data_src, copy_size); | ||
} | ||
} | ||
} | ||
|
||
template <int N> | ||
inline OMStatus BroadcastTo(const core::OMRuntimeShape &unextended_input_shape, | ||
const uint8_t *input_data, | ||
const core::OMRuntimeShape &unextended_output_shape, | ||
uint8_t *output_data, core::OMDataType data_type) | ||
{ | ||
NdArrayDesc<N> input_desc; | ||
NdArrayDesc<N> output_desc; | ||
copyDimsToDesc(core::OMRuntimeShape::extendedShape(N, unextended_input_shape), &input_desc); | ||
copyDimsToDesc(core::OMRuntimeShape::extendedShape(N, unextended_output_shape), &output_desc); | ||
|
||
// Get the last dimension has broadcasting. At this dimension, the data is | ||
// copied from input tensor to output tensor. | ||
int last_broadcast_dim = -1; | ||
for (int i = N - 1; i >= 0; --i) | ||
{ | ||
if (input_desc.extents[i] != output_desc.extents[i]) | ||
{ | ||
last_broadcast_dim = i; | ||
break; | ||
} | ||
} | ||
|
||
// If non-broadcasting, just copy data from input to output tensor. | ||
if (last_broadcast_dim == -1) | ||
{ | ||
memcpy(output_data, input_data, unextended_input_shape.flatSize() * sizeof(data_type)); | ||
return Ok; | ||
} | ||
|
||
// Broadcasting using memcpy. | ||
int indexes[N] = {0}; | ||
BroadcastImpl<N>(input_desc, input_data, output_desc, output_data, indexes, 0, last_broadcast_dim, | ||
core::getOMDataTypeSize(data_type)); | ||
|
||
return Ok; | ||
} | ||
|
||
} // namespace pal | ||
} // namespace execute | ||
} // namespace onert_micro | ||
|
||
#endif // ONERT_MICRO_EXECUTE_PAL_BROADCAST_TO_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
REGISTER_CUSTOM_KERNEL(BROADCAST_TO, "BroadcastTo") |
94 changes: 94 additions & 0 deletions
94
onert-micro/onert-micro/include/test_models/broadcast_to/FloatBroadcastToKernel.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,94 @@ | ||
/* | ||
* 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_BROADCAST_TO_KERNEL_H | ||
#define ONERT_MICRO_TEST_MODELS_FLOAT_BROADCAST_TO_KERNEL_H | ||
|
||
#include "TestDataBroadcastToBase.h" | ||
|
||
namespace onert_micro | ||
{ | ||
namespace test_model | ||
{ | ||
namespace broadcast_to_float | ||
{ | ||
/* | ||
* BroadcastTo Kernel: | ||
* | ||
* Input(2, 3) | ||
* | | ||
* BroadcastTo | ||
* | | ||
* Output(1, 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, | ||
0x50, 0x00, 0x00, 0x00, 0x98, 0x01, 0x00, 0x00, 0xc8, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x3c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 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, 0x6c, 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, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | ||
0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x54, 0x00, 0x54, 0x69, 0x64, 0x78, 0x00, 0x02, | ||
0x08, 0x07, 0x02, 0x01, 0x02, 0x00, 0x02, 0x04, 0x04, 0x04, 0x24, 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, 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x9c, 0xff, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | ||
0x06, 0x00, 0x00, 0x00, 0x62, 0x63, 0x5f, 0x6f, 0x66, 0x6d, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 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, 0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, | ||
0x62, 0x63, 0x5f, 0x73, 0x68, 0x61, 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, 0x01, 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, 0x14, 0x00, 0x00, 0x00, | ||
0x08, 0x00, 0x00, 0x00, 0x62, 0x63, 0x5f, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x00, 0x00, 0x00, 0x00, | ||
0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, | ||
0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, | ||
0x0b, 0x00, 0x00, 0x00, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x54, 0x6f, 0x00, | ||
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 = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}; | ||
|
||
const std::vector<float> reference_output_data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}; | ||
|
||
} // namespace broadcast_to_float | ||
|
||
class TestDataFloatBroadcastTo : public TestDataBroadcastToBase<float> | ||
{ | ||
public: | ||
TestDataFloatBroadcastTo() | ||
{ | ||
_input_data = broadcast_to_float::input_data; | ||
_reference_output_data = broadcast_to_float::reference_output_data; | ||
_test_kernel_model_circle = broadcast_to_float::test_kernel_model_circle; | ||
} | ||
|
||
~TestDataFloatBroadcastTo() override = default; | ||
}; | ||
|
||
} // namespace test_model | ||
} // namespace onert_micro | ||
|
||
#endif // ONERT_MICRO_TEST_MODELS_FLOAT_BROADCAST_TO_KERNEL_H |
93 changes: 93 additions & 0 deletions
93
onert-micro/onert-micro/include/test_models/broadcast_to/NegBroadcastToKernel.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,93 @@ | ||
/* | ||
* 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_BROADCAST_TO_KERNEL_H | ||
#define ONERT_MICRO_TEST_MODELS_NEG_BROADCAST_TO_KERNEL_H | ||
|
||
#include "test_models/TestDataBase.h" | ||
|
||
namespace onert_micro | ||
{ | ||
namespace test_model | ||
{ | ||
namespace neg_input_output_type_mismatch_broadcast_to_kernel | ||
{ | ||
/* | ||
* BroadcastTo Kernel with input output type mismatch: | ||
* | ||
* Input(2, 3) - Float32 | ||
* | | ||
* BroadcastTo | ||
* | | ||
* Output(1, 2, 3) - 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, | ||
0x50, 0x00, 0x00, 0x00, 0x9c, 0x01, 0x00, 0x00, 0xcc, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x3c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 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, 0x6c, 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, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | ||
0x24, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x54, 0x00, 0x54, 0x69, 0x64, 0x78, 0x00, 0x02, | ||
0x08, 0x07, 0x02, 0x01, 0x02, 0x00, 0x02, 0x04, 0x04, 0x04, 0x24, 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, 0x80, 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, | ||
0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x62, 0x63, 0x5f, 0x6f, 0x66, 0x6d, 0x00, 0x00, | ||
0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 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, 0x14, 0x00, 0x00, 0x00, | ||
0x08, 0x00, 0x00, 0x00, 0x62, 0x63, 0x5f, 0x73, 0x68, 0x61, 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, | ||
0x01, 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, | ||
0x14, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x62, 0x63, 0x5f, 0x69, 0x6e, 0x70, 0x75, 0x74, | ||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x04, 0x00, | ||
0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x20, 0x0b, 0x00, 0x00, 0x00, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, | ||
0x74, 0x54, 0x6f, 0x00, 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_broadcast_to_kernel | ||
|
||
class NegTestDataInputOutputTypeMismatchBroadcastToKernel : public NegTestDataBase | ||
{ | ||
public: | ||
NegTestDataInputOutputTypeMismatchBroadcastToKernel() | ||
{ | ||
_test_kernel_model_circle = | ||
neg_input_output_type_mismatch_broadcast_to_kernel::test_kernel_model_circle; | ||
} | ||
|
||
~NegTestDataInputOutputTypeMismatchBroadcastToKernel() 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_BROADCAST_TO_KERNEL_H |
61 changes: 61 additions & 0 deletions
61
onert-micro/onert-micro/include/test_models/broadcast_to/TestDataBroadcastToBase.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_BROADCAST_TO_KERNEL_BASE_H | ||
#define ONERT_MICRO_TEST_MODELS_BROADCAST_TO_KERNEL_BASE_H | ||
|
||
#include "test_models/TestDataBase.h" | ||
#include <cassert> | ||
|
||
namespace onert_micro | ||
{ | ||
namespace test_model | ||
{ | ||
|
||
template <typename T> class TestDataBroadcastToBase : public TestDataBase<T> | ||
{ | ||
public: | ||
TestDataBroadcastToBase() = 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_BROADCAST_TO_KERNEL_BASE_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What can be the depth of recursion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is 5, you can find it in
ONE/onert-micro/onert-micro/src/execute/kernels/BroadcastTo.cpp
Line 35 in f2b6e69