diff --git a/compiler/luci/export/include/luci/CircleExporter.h b/compiler/luci/export/include/luci/CircleExporter.h index 0584c623cfa..de064ea8444 100644 --- a/compiler/luci/export/include/luci/CircleExporter.h +++ b/compiler/luci/export/include/luci/CircleExporter.h @@ -36,14 +36,9 @@ class CircleExporter virtual ~Contract() = default; public: // Client -> Exporter - // Input Graph (to be exported) - // Exporter expects a loco graph that consists of Circle nodes - virtual loco::Graph *graph(void) const = 0; - // Input Module (to be exported) // Exporter expects a luci module that consists of loco graphs - // TODO make this pure virtual - virtual luci::Module *module(void) const; + virtual luci::Module *module(void) const = 0; public: // Exporter -> Client // Exporter calls store for export data diff --git a/compiler/luci/export/include/luci/CircleFileExpContract.h b/compiler/luci/export/include/luci/CircleFileExpContract.h index 8ef1b5e0cf6..a06ebe9963e 100644 --- a/compiler/luci/export/include/luci/CircleFileExpContract.h +++ b/compiler/luci/export/include/luci/CircleFileExpContract.h @@ -40,7 +40,6 @@ struct CircleFileExpContract : public luci::CircleExporter::Contract virtual ~CircleFileExpContract() = default; public: - loco::Graph *graph(void) const final { return nullptr; } luci::Module *module(void) const final { return _module; } public: diff --git a/compiler/luci/export/src/CircleExporter.cpp b/compiler/luci/export/src/CircleExporter.cpp index 125df780212..6f5066823c2 100644 --- a/compiler/luci/export/src/CircleExporter.cpp +++ b/compiler/luci/export/src/CircleExporter.cpp @@ -26,9 +26,6 @@ namespace luci { -// TODO remove this -Module *CircleExporter::Contract::module(void) const { return nullptr; } - CircleExporter::CircleExporter() { // NOTHING TO DO @@ -48,17 +45,10 @@ bool CircleExporter::invoke(Contract *contract) const return contract->store(ptr, size); } - auto graph = contract->graph(); - if (graph == nullptr) - return false; - - CircleExporterImpl impl(graph); - - const char *ptr = impl.getBufferPointer(); - const size_t size = impl.getBufferSize(); + // NOTE some unit tests calls with nullptr module, cannot add assert here + // TODO fix those unit tests and add assert(false) - // we just send one time - return contract->store(ptr, size); + return false; } } // namespace luci diff --git a/compiler/luci/export/src/CircleExporter.test.cpp b/compiler/luci/export/src/CircleExporter.test.cpp index 5898f9d653e..c76d983972d 100644 --- a/compiler/luci/export/src/CircleExporter.test.cpp +++ b/compiler/luci/export/src/CircleExporter.test.cpp @@ -33,12 +33,12 @@ class SampleGraphContract : public luci::CircleExporter::Contract SampleGraphContract() : luci::CircleExporter::Contract(), _buffer(new std::vector) { // create needed entities - _g = loco::make_graph(); - auto graph_input = _g->inputs()->create(); - auto graph_output = _g->outputs()->create(); - input_node = _g->nodes()->create(); - output_node = _g->nodes()->create(); - relu_node = _g->nodes()->create(); + auto g = loco::make_graph(); + auto graph_input = g->inputs()->create(); + auto graph_output = g->outputs()->create(); + input_node = g->nodes()->create(); + output_node = g->nodes()->create(); + relu_node = g->nodes()->create(); // link nodes and link them to graph relu_node->features(input_node); @@ -57,9 +57,12 @@ class SampleGraphContract : public luci::CircleExporter::Contract graph_output->shape({1, 2, 3, 4}); graph_output->dtype(loco::DataType::FLOAT32); + + _m = std::unique_ptr{new luci::Module}; + _m->add(std::move(g)); } - loco::Graph *graph(void) const override { return _g.get(); } + luci::Module *module(void) const override { return _m.get(); } public: bool store(const char *ptr, const size_t size) const override @@ -77,7 +80,7 @@ class SampleGraphContract : public luci::CircleExporter::Contract luci::CircleRelu *relu_node; private: - std::unique_ptr _g; + std::unique_ptr _m; std::unique_ptr> _buffer; }; diff --git a/compiler/luci/export/src/CircleExporterImpl.cpp b/compiler/luci/export/src/CircleExporterImpl.cpp index 2a7384663ac..00e7ace2c99 100644 --- a/compiler/luci/export/src/CircleExporterImpl.cpp +++ b/compiler/luci/export/src/CircleExporterImpl.cpp @@ -133,7 +133,6 @@ namespace luci using namespace circle; using namespace flatbuffers; -CircleExporterImpl::CircleExporterImpl(loco::Graph *graph) { exportGraph(graph); } CircleExporterImpl::CircleExporterImpl(Module *module) { exportModule(module); } ::flatbuffers::Offset<::circle::SubGraph> @@ -148,61 +147,6 @@ CircleExporterImpl::exportSubgraph(SerializedGraphData &gd) return subgraph; } -void CircleExporterImpl::exportGraph(loco::Graph *graph) -{ - // do graph optimization - optimize(graph); - - _builder.Clear(); - - SerializedModelData md; - SerializedGraphData gd; - - // This version is taken from comment in fbs - constexpr uint32_t version = 0; - - // set Subgraph name - gd._name = graph->name(); - - // TODO set this value properly - gd._data_format = circle::DataFormat::DataFormat_CHANNELS_LAST; - - // prepare model data - prepareModelData(_builder, md); - - // parse graph into SerializedModelData structure - exportOpDefinedTensors(graph, _builder, md, gd); - - // NOTE Invoke these register functions only after each node is annotated with its tensor_index - registerGraphInputTensors(graph, gd); - registerGraphOutputTensors(graph, gd); - - exportNodes(graph, _builder, md, gd); - - // encode operator codes - auto operator_codes = encodeOperatorCodes(_builder, md._operator_codes); - - // Subgraphs - Offset subgraph = exportSubgraph(gd); - auto subgraphs = _builder.CreateVector(std::vector>{subgraph}); - - // Description - std::string description_str = "nnpackage"; - auto description = _builder.CreateString(description_str); - - // Metadata - auto metadata_vec = createCircleMetadataVector(_builder, md); - auto metadata = _builder.CreateVector(std::vector>(metadata_vec)); - - // create array of buffers - auto buffers = _builder.CreateVector(md._buffers); - - // Model - auto model_offset = CreateModel(_builder, version, operator_codes, subgraphs, description, - buffers, 0 /* metadata_buffer */, metadata); - FinishModelBuffer(_builder, model_offset); -} - void CircleExporterImpl::exportModule(Module *module) { assert(module->size() > 0); @@ -248,7 +192,7 @@ void CircleExporterImpl::exportModule(Module *module) auto operator_codes = encodeOperatorCodes(_builder, md._operator_codes); // Description - std::string description_str = "nnpackage"; + std::string description_str = "ONE-luci/export"; auto description = _builder.CreateString(description_str); // Metadata diff --git a/compiler/luci/export/src/CircleExporterImpl.h b/compiler/luci/export/src/CircleExporterImpl.h index 069f62afd4a..5911fadba43 100644 --- a/compiler/luci/export/src/CircleExporterImpl.h +++ b/compiler/luci/export/src/CircleExporterImpl.h @@ -38,7 +38,6 @@ class CircleExporterImpl CircleExporterImpl() = delete; ~CircleExporterImpl() = default; - explicit CircleExporterImpl(loco::Graph *graph); explicit CircleExporterImpl(Module *module); /** @@ -59,12 +58,6 @@ class CircleExporterImpl */ flatbuffers::Offset exportSubgraph(SerializedGraphData &gd); - /** - * @brief root function that writes graph into internal buffer - * @param graph - */ - void exportGraph(loco::Graph *graph); - /** * @brief root function that writes Module into internal buffer * @param module diff --git a/compiler/luci/service/src/CircleShapeInferenceRule.cpp b/compiler/luci/service/src/CircleShapeInferenceRule.cpp index 63eb4fb7e37..e9c53cc4833 100644 --- a/compiler/luci/service/src/CircleShapeInferenceRule.cpp +++ b/compiler/luci/service/src/CircleShapeInferenceRule.cpp @@ -237,27 +237,33 @@ loco::NodeShape use_paddings(const CIRCLENODE *node, const luci::CircleConst *pa { int32_t idx = ni * 2; int value = input_shape.dim(ni).value(); - if (paddings->dtype() == S32) + if (!input_shape.dim(ni).known()) { - value += paddings->at(idx + 0); // left - value += paddings->at(idx + 1); // right + output_shape.dim(ni).unset(); } else { - auto pl = paddings->at(idx + 0); - auto pr = paddings->at(idx + 1); - auto max = static_cast(std::numeric_limits::max()); - auto low = static_cast(std::numeric_limits::lowest()); - LUCI_ASSERT(pl <= max, "paddings is over 32 bit limit"); - LUCI_ASSERT(pl >= low, "paddings is over 32 bit limit"); - LUCI_ASSERT(pr <= max, "paddings is over 32 bit limit"); - LUCI_ASSERT(pr >= low, "paddings is over 32 bit limit"); - value += static_cast(pl); // left - value += static_cast(pr); // right + if (paddings->dtype() == S32) + { + value += paddings->at(idx + 0); // left + value += paddings->at(idx + 1); // right + } + else + { + auto pl = paddings->at(idx + 0); + auto pr = paddings->at(idx + 1); + auto max = static_cast(std::numeric_limits::max()); + auto low = static_cast(std::numeric_limits::lowest()); + LUCI_ASSERT(pl <= max, "paddings is over 32 bit limit"); + LUCI_ASSERT(pl >= low, "paddings is over 32 bit limit"); + LUCI_ASSERT(pr <= max, "paddings is over 32 bit limit"); + LUCI_ASSERT(pr >= low, "paddings is over 32 bit limit"); + value += static_cast(pl); // left + value += static_cast(pr); // right + } + output_shape.dim(ni) = value; } - output_shape.dim(ni) = value; } - return loco::NodeShape{output_shape}; } @@ -2599,7 +2605,8 @@ bool CircleShapeInferenceRule::infer(const loco::Node *node, loco::NodeShape &sh else shape = circle_node->accept(&alg); } - + VERBOSE(l, 1) << "[icodo] shape status: " << is_shape_undefined << ", " << is_shape_none << ", " + << is_scalar; VERBOSE(l, 1) << "[luci] shape: " << circle_node->name(); VERBOSE(l, 1) << " own_shape: " << own_shape(circle_node) << " -> infer: " << shape.as(); diff --git a/compiler/luci/service/src/Nodes/CirclePad.test.cpp b/compiler/luci/service/src/Nodes/CirclePad.test.cpp index 1d5f8375e1f..7f66ec86568 100644 --- a/compiler/luci/service/src/Nodes/CirclePad.test.cpp +++ b/compiler/luci/service/src/Nodes/CirclePad.test.cpp @@ -16,6 +16,8 @@ #include "luci/Service/CircleNodeClone.h" +#include "luci/Service/CircleShapeInference.h" + #include TEST(CloneNodeTest, clone_Pad) @@ -31,3 +33,42 @@ TEST(CloneNodeTest, clone_Pad) auto cloned_pad = dynamic_cast(cloned); ASSERT_NE(nullptr, cloned_pad); } + +TEST(ShapeRuleTest, padding_dynamic_shape) +{ + luci::CirclePad pad; + luci::CircleInput input; + // Use circle input as paddings + luci::CircleConst padddings; + + loco::TensorShape shape; + luci::sinf::Rule shape_inf_rule; + + input.shape({1, 2, 3, 4}); + input.shape_status(luci::ShapeStatus::VALID); + input.dim(2).unset(); + + padddings.dtype(loco::DataType::S64); + padddings.shape({4, 2}); + padddings.shape_status(luci::ShapeStatus::VALID); + + const loco::DataType S64 = loco::DataType::S64; + uint32_t t = 64 * 8; + padddings.size(t); + + pad.input(&input); + pad.paddings(&padddings); + + ASSERT_TRUE(shape_inf_rule.infer(&pad, shape)); + ASSERT_EQ(shape.rank(), 4); + ASSERT_TRUE(shape.dim(0).known()); + ASSERT_TRUE(shape.dim(1).known()); + ASSERT_FALSE(shape.dim(2).known()); + ASSERT_TRUE(shape.dim(3).known()); + + ASSERT_EQ(1, shape.dim(0).value()); + ASSERT_EQ(2, shape.dim(1).value()); + ASSERT_EQ(0, shape.dim(2).value()); + ASSERT_EQ(4, shape.dim(3).value()); + pad.drop(); +} diff --git a/compiler/luci/tester/src/WriteTester.cpp b/compiler/luci/tester/src/WriteTester.cpp index 0d3a1efa220..e5b31e16dc6 100644 --- a/compiler/luci/tester/src/WriteTester.cpp +++ b/compiler/luci/tester/src/WriteTester.cpp @@ -42,11 +42,6 @@ void show_error_message(const char *progname, std::ostream &os, const std::strin struct CircleExpContract : public luci::CircleExporter::Contract { public: - CircleExpContract(loco::Graph *graph, const std::string &filename) - : _graph(graph), _filepath(filename) - { - // NOTHING TO DO - } CircleExpContract(luci::Module *module, const std::string &filename) : _module(module), _filepath(filename) { @@ -55,15 +50,12 @@ struct CircleExpContract : public luci::CircleExporter::Contract virtual ~CircleExpContract() = default; public: - loco::Graph *graph(void) const final { return _graph; } - luci::Module *module(void) const final { return _module; } public: bool store(const char *ptr, const size_t size) const final; private: - loco::Graph *_graph{nullptr}; luci::Module *_module{nullptr}; const std::string _filepath; }; diff --git a/onert-micro/onert-micro/include/execute/kernels/ComparisonCommon.h b/onert-micro/onert-micro/include/execute/kernels/ComparisonCommon.h index 5aea894d47f..fc08257f156 100644 --- a/onert-micro/onert-micro/include/execute/kernels/ComparisonCommon.h +++ b/onert-micro/onert-micro/include/execute/kernels/ComparisonCommon.h @@ -110,8 +110,8 @@ template void evalComparisonGeneric(OMRuntimeKernel *runtime_kernel } } -template -void evalQuantizedComparisonGeneric(OMRuntimeKernel *runtime_kernel, bool F(T, T)) +template +void evalQuantizedComparisonGeneric(OMRuntimeKernel *runtime_kernel, bool F(AccType, AccType)) { const circle::Tensor *input1 = nullptr; const circle::Tensor *input2 = nullptr; diff --git a/onert-micro/onert-micro/include/pal/common/PALComparisons.h b/onert-micro/onert-micro/include/pal/common/PALComparisons.h index 0f37d2f19c8..0770196ff32 100644 --- a/onert-micro/onert-micro/include/pal/common/PALComparisons.h +++ b/onert-micro/onert-micro/include/pal/common/PALComparisons.h @@ -71,11 +71,11 @@ inline void ComparisonNoScaling(const int64_t flat_size, const T *input1_data, c } } -template +template inline void BroadcastComparison4DSlowWithScaling( const core::ComparisonParams &op_params, const core::OMRuntimeShape &unextended_input1_shape, const T *input1_data, const core::OMRuntimeShape &unextended_input2_shape, const T *input2_data, - const core::OMRuntimeShape &unextended_output_shape, bool *output_data, bool F(T, T)) + const core::OMRuntimeShape &unextended_output_shape, bool *output_data, bool F(AccType, AccType)) { const BroadcastComparison4DSlowCommon dims = BroadcastComparison4DSlowPreprocess( unextended_input1_shape, unextended_input2_shape, unextended_output_shape); @@ -118,10 +118,10 @@ inline void BroadcastComparison4DSlowWithScaling( } } -template +template inline void ComparisonWithScaling(const core::ComparisonParams &op_params, const int64_t flat_size, const T *input1_data, const T *input2_data, bool *output_data, - bool F(T, T)) + bool F(AccType, AccType)) { int left_shift = op_params.left_shift; int32_t input1_offset = op_params.input1_offset; diff --git a/onert-micro/onert-micro/include/test_models/less/S8LessKernel.h b/onert-micro/onert-micro/include/test_models/less/S8LessKernel.h new file mode 100644 index 00000000000..f2762487cd9 --- /dev/null +++ b/onert-micro/onert-micro/include/test_models/less/S8LessKernel.h @@ -0,0 +1,192 @@ +/* + * 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_LESS_KERNEL_S8_H +#define ONERT_MICRO_TEST_MODELS_LESS_KERNEL_S8_H + +#include "TestDataLessBase.h" + +namespace onert_micro +{ +namespace test_model +{ +namespace less_s8_with_no_broadcasting +{ + +/* + * Less Kernel: + * + * Input_1(1, 1, 4, 3) Input_2(1, 1, 4, 3) + * scale: 0.0078431373 scale: 0.008431373 + * \ / + * Less(no broadcast) + * | + * Output(1, 1, 4, 3) + */ + +const unsigned char test_kernel_model_circle[] = { + + 0x1c, 0x00, 0x00, 0x00, 0x43, 0x49, 0x52, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, + 0x00, 0x14, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x10, 0x00, 0x04, 0x00, 0x0e, 0x00, + 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0x00, 0x2c, + 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x88, 0xff, 0xff, 0xff, 0x8c, 0xff, 0xff, + 0xff, 0x90, 0xff, 0xff, 0xff, 0x94, 0xff, 0xff, 0xff, 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, + 0x60, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x6c, 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, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x07, + 0x00, 0x08, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, + 0x00, 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, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xcc, 0x00, 0x00, 0x00, 0x44, 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, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x6f, 0x66, 0x6d, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x8a, 0xff, 0xff, + 0xff, 0x14, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x09, 0x4c, 0x00, 0x00, 0x00, 0x7c, 0xff, 0xff, 0xff, 0x30, 0x00, 0x00, 0x00, 0x24, + 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0xbe, 0x23, 0x0a, 0x3c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x42, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x04, 0x00, 0x00, 0x00, 0x69, 0x66, 0x6d, 0x32, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x14, + 0x00, 0x13, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, + 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x54, + 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x81, 0x80, 0x00, 0x3c, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xfe, 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x04, 0x00, 0x00, 0x00, + 0x69, 0x66, 0x6d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 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, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, + 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 input1_data = {36, 4, 49, 84, 22, 40, 74, 97, 25, 26, 69, 37}; + +const std::vector input2_data = {66, 62, 58, 89, 2, 29, 37, 88, 64, 83, 73, 33}; + +const std::vector reference_output_data = {true, true, true, true, false, false, + false, false, true, true, true, false}; + +} // namespace less_s8_with_no_broadcasting + +namespace neg_less_s8_with_no_broadcasting +{ + +/* + * Less Kernel with input type mismatch: + * + * Input_1(1, 2, 2, 3) INT8 Input_2(1, 2, 2, 3) UINT8 + * \ / + * Less(no broadcast) + * | + * Output(1, 2, 2, 3) + */ + +const unsigned char test_kernel_model_circle[] = { + 0x1c, 0x00, 0x00, 0x00, 0x43, 0x49, 0x52, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x10, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0x00, 0x2c, 0x02, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x88, 0xff, 0xff, 0xff, 0x8c, 0xff, 0xff, 0xff, 0x90, 0xff, 0xff, 0xff, + 0x94, 0xff, 0xff, 0xff, 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, 0x60, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x6c, 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, 0x14, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, + 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, + 0x04, 0x00, 0x00, 0x00, 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, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xcc, 0x00, 0x00, 0x00, 0x44, 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, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x6f, 0x66, 0x6d, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x8a, 0xff, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x4c, 0x00, 0x00, 0x00, + 0x7c, 0xff, 0xff, 0xff, 0x30, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xbe, 0x23, 0x0a, 0x3c, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x43, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x69, 0x66, 0x6d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x18, 0x00, 0x14, 0x00, 0x13, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, + 0x54, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x81, 0x80, 0x00, 0x3c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x42, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x04, 0x00, 0x00, 0x00, 0x69, 0x66, 0x6d, 0x31, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x03, 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, + 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 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 input1_data = {36, 4, 49, 84, 22, 40, 74, 97, 25, 26, 69, 37}; + +const std::vector input2_data = {66, 62, 58, 89, 2, 29, 37, 88, 64, 83, 73, 33}; + +const std::vector reference_output_data = {true, true, true, true, false, false, + false, false, true, true, true, false}; + +} // namespace neg_less_s8_with_no_broadcasting + +class TestDataS8Less : public TestDataLessBase +{ +public: + explicit TestDataS8Less(bool is_with_broadcast, bool is_neg) + : TestDataLessBase(is_with_broadcast) + { + if (is_with_broadcast) + { + assert(false && "Not impl yet"); + } + else + { + if (is_neg) + { + _input1_data = neg_less_s8_with_no_broadcasting::input1_data; + _input2_data = neg_less_s8_with_no_broadcasting::input2_data; + _reference_output_data = neg_less_s8_with_no_broadcasting::reference_output_data; + _test_kernel_model_circle = neg_less_s8_with_no_broadcasting::test_kernel_model_circle; + } + else + { + _input1_data = less_s8_with_no_broadcasting::input1_data; + _input2_data = less_s8_with_no_broadcasting::input2_data; + _reference_output_data = less_s8_with_no_broadcasting::reference_output_data; + _test_kernel_model_circle = less_s8_with_no_broadcasting::test_kernel_model_circle; + } + } + } + + ~TestDataS8Less() override = default; +}; + +} // namespace test_model +} // namespace onert_micro + +#endif // ONERT_MICRO_TEST_MODELS_LESS_KERNEL_QUANT_H diff --git a/onert-micro/onert-micro/src/execute/kernels/Less.cpp b/onert-micro/onert-micro/src/execute/kernels/Less.cpp index 6d27f66abd3..b815849cf6f 100644 --- a/onert-micro/onert-micro/src/execute/kernels/Less.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/Less.cpp @@ -73,7 +73,12 @@ OMStatus onert_micro::execute::execute_kernel_CircleLess(const OMExecuteArgs &ex break; #ifndef DIS_QUANT case circle::TensorType_UINT8: - evalQuantizedComparisonGeneric(&runtime_kernel, onert_micro::execute::pal::LessFn); + evalQuantizedComparisonGeneric(&runtime_kernel, + onert_micro::execute::pal::LessFn); + break; + case circle::TensorType_INT8: + evalQuantizedComparisonGeneric(&runtime_kernel, + onert_micro::execute::pal::LessFn); break; #endif // DIS_QUANT diff --git a/onert-micro/onert-micro/src/execute/kernels/tests/Less.test.cpp b/onert-micro/onert-micro/src/execute/kernels/tests/Less.test.cpp index f7b8b8f08bb..61aa5419c8d 100644 --- a/onert-micro/onert-micro/src/execute/kernels/tests/Less.test.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/tests/Less.test.cpp @@ -19,6 +19,7 @@ #include "test_models/less/FloatLessKernel.h" #include "test_models/less/IntLessKernel.h" #include "test_models/less/QuantLessKernel.h" +#include "test_models/less/S8LessKernel.h" #include "test_models/less/NegTestDataLessKernel.h" namespace onert_micro @@ -124,6 +125,26 @@ TEST_F(LessTest, Quant_P) EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0)); } +TEST_F(LessTest, S8_P) +{ + const bool is_with_broadcast = false; + onert_micro::test_model::TestDataS8Less test_data_kernel(is_with_broadcast, false); + + std::vector output_data_vector = + onert_micro::execute::testing::checkKernel(2, &test_data_kernel); + + EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0)); +} + +TEST_F(LessTest, S8_NEG) +{ + const bool is_with_broadcast = false; + onert_micro::test_model::TestDataS8Less test_data_kernel(is_with_broadcast, true); + + EXPECT_DEATH((onert_micro::execute::testing::checkKernel(2, &test_data_kernel)), + ""); +} + TEST_F(LessTest, Quant_NEG) { const bool is_with_broadcast = false; diff --git a/runtime/onert/core/include/ir/train/Checkpoint.h b/runtime/onert/core/include/ir/train/Checkpoint.h index d62f9d69b5e..8edc8a0aad5 100644 --- a/runtime/onert/core/include/ir/train/Checkpoint.h +++ b/runtime/onert/core/include/ir/train/Checkpoint.h @@ -19,6 +19,8 @@ namespace onert { +namespace ir +{ namespace train { namespace checkpoint @@ -46,6 +48,7 @@ constexpr uint8_t SCHEMA_VERSION = 1; } // namespace checkpoint } // namespace train +} // namespace ir } // namespace onert #endif // __ONERT_IR_TRAIN_CHECKPOINT_H__