Skip to content
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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion onert-micro/onert-micro/include/core/OMKernelType.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ enum OMKernelType

enum OMBuilderCustomID
{
CUSTOM_custom_gru,
CUSTOM_BROADCAST_TO,
};

#define REGISTER_KERNEL(builtin_operator, name) BuiltinOperator_##builtin_operator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ class KernelCustomExecuteRegistry
return UnknownError;
}
const auto builder_id_offset = size_t(core::OMBuilderID::BuiltinOperatorsSize);
builder_id_opcode -= builder_id_offset - 1;
builder_id_opcode -= (builder_id_offset + 1);
assert(builder_id_opcode <
size_t(core::OMBuilderID::Size) - size_t(core::OMBuilderID::BuiltinOperatorsSize) - 1);

*execute_func = _operator_execute[builder_id_opcode];
return Ok;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ class KernelCustomConfigureRegistry
return UnknownError;
}
const auto builder_id_offset = size_t(core::OMBuilderID::BuiltinOperatorsSize);
builder_id_opcode -= builder_id_offset - 1;

builder_id_opcode -= (builder_id_offset + 1);
assert(builder_id_opcode <
size_t(core::OMBuilderID::Size) - size_t(core::OMBuilderID::BuiltinOperatorsSize) - 1);
*configure_func = _operator_configure[builder_id_opcode];
return Ok;
}
Expand Down
114 changes: 114 additions & 0 deletions onert-micro/onert-micro/include/pal/common/PALBroadcastTo.h
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])
Copy link
Contributor

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?

Copy link
Contributor Author

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

{
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REGISTER_CUSTOM_KERNEL(BROADCAST_TO, "BroadcastTo")
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
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
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
Loading