summaryrefslogtreecommitdiff
path: root/tests/nnfw_api/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/nnfw_api/src')
-rw-r--r--tests/nnfw_api/src/CircleGen.cc380
-rw-r--r--tests/nnfw_api/src/CircleGen.h199
-rw-r--r--tests/nnfw_api/src/GenModelTest.h436
-rw-r--r--tests/nnfw_api/src/GenModelTests.cc195
-rw-r--r--tests/nnfw_api/src/ModelTestDynamicTensor.cc516
-rw-r--r--tests/nnfw_api/src/ModelTestInputReshaping.cc97
-rw-r--r--tests/nnfw_api/src/NNPackages.cc98
-rw-r--r--tests/nnfw_api/src/NNPackages.h95
-rw-r--r--tests/nnfw_api/src/RegressionTests.cc178
-rw-r--r--tests/nnfw_api/src/ValidationTestAddModelLoaded.cc124
-rw-r--r--tests/nnfw_api/src/ValidationTestAddSessionPrepared.cc194
-rw-r--r--tests/nnfw_api/src/ValidationTestFourAddModelsSetInput.cc50
-rw-r--r--tests/nnfw_api/src/ValidationTestSessionCreated.cc120
-rw-r--r--tests/nnfw_api/src/ValidationTestSingleSession.cc111
-rw-r--r--tests/nnfw_api/src/common.cc40
-rw-r--r--tests/nnfw_api/src/common.h26
-rw-r--r--tests/nnfw_api/src/fixtures.h208
-rw-r--r--tests/nnfw_api/src/main.cc39
-rw-r--r--tests/nnfw_api/src/one_op_tests/Add.cc166
-rw-r--r--tests/nnfw_api/src/one_op_tests/ArgMax.cc122
-rw-r--r--tests/nnfw_api/src/one_op_tests/AveragePool2D.cc124
-rw-r--r--tests/nnfw_api/src/one_op_tests/Cast.cc159
-rw-r--r--tests/nnfw_api/src/one_op_tests/Concat.cc210
-rw-r--r--tests/nnfw_api/src/one_op_tests/Cos.cc50
-rw-r--r--tests/nnfw_api/src/one_op_tests/Equal.cc69
-rw-r--r--tests/nnfw_api/src/one_op_tests/FullyConnected.cc90
-rw-r--r--tests/nnfw_api/src/one_op_tests/If.cc132
-rw-r--r--tests/nnfw_api/src/one_op_tests/InstanceNorm.cc57
-rw-r--r--tests/nnfw_api/src/one_op_tests/L2Normalization.cc36
-rw-r--r--tests/nnfw_api/src/one_op_tests/LeakyRelu.cc48
-rw-r--r--tests/nnfw_api/src/one_op_tests/LogSoftmax.cc51
-rw-r--r--tests/nnfw_api/src/one_op_tests/OneHot.cc201
-rw-r--r--tests/nnfw_api/src/one_op_tests/Pad.cc93
-rw-r--r--tests/nnfw_api/src/one_op_tests/PadV2.cc114
-rw-r--r--tests/nnfw_api/src/one_op_tests/Rank.cc53
-rw-r--r--tests/nnfw_api/src/one_op_tests/ResizeBilinear.cc75
-rw-r--r--tests/nnfw_api/src/one_op_tests/ResizeNearestNeighbor.cc39
-rw-r--r--tests/nnfw_api/src/one_op_tests/Reverse.cc59
-rw-r--r--tests/nnfw_api/src/one_op_tests/Split.cc65
-rw-r--r--tests/nnfw_api/src/one_op_tests/StridedSlice.cc43
-rw-r--r--tests/nnfw_api/src/one_op_tests/Tile.cc136
-rw-r--r--tests/nnfw_api/src/one_op_tests/Transpose.cc145
-rw-r--r--tests/nnfw_api/src/one_op_tests/While.cc195
43 files changed, 0 insertions, 5638 deletions
diff --git a/tests/nnfw_api/src/CircleGen.cc b/tests/nnfw_api/src/CircleGen.cc
deleted file mode 100644
index 8040f7dfb..000000000
--- a/tests/nnfw_api/src/CircleGen.cc
+++ /dev/null
@@ -1,380 +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.
- */
-
-#include "CircleGen.h"
-
-CircleGen::CircleGen() : _subgraph_contexts(1) // Create primary subgraph
-{
- // 0th buffer is always the empty buffer for non-const tensors
- addBuffer(nullptr, 0);
-}
-
-template <typename T> uint32_t addBuffer(const std::vector<T> &buf_vec)
-{
- auto buf = reinterpret_cast<const uint8_t *>(buf_vec.data());
- auto size = buf_vec.size() * sizeof(T);
- return addBuffer(buf, size);
-}
-
-uint32_t CircleGen::addBuffer(const uint8_t *buf, size_t size)
-{
- uint32_t ind = _buffers.size();
- _buffers.emplace_back(buildBuffer(buf, size));
- return ind;
-}
-
-uint32_t CircleGen::addTensor(const TensorParams &params)
-{
- uint32_t ind = curSubgCtx().tensors.size();
- curSubgCtx().tensors.emplace_back(buildTensor(params));
- return ind;
-}
-
-uint32_t CircleGen::addTensor(const TensorParams &params, const SparsityParams &sp)
-{
- uint32_t ind = curSubgCtx().tensors.size();
- curSubgCtx().tensors.emplace_back(buildTensor(params, sp));
- return ind;
-}
-
-void CircleGen::setInputsAndOutputs(const std::vector<int> &inputs, const std::vector<int> &outputs)
-{
- curSubgCtx().inputs = inputs;
- curSubgCtx().outputs = outputs;
-}
-
-uint32_t CircleGen::nextSubgraph()
-{
- uint32_t ind = _subgraph_contexts.size();
- _subgraph_contexts.push_back({});
- return ind;
-}
-
-CircleBuffer CircleGen::finish()
-{
- std::vector<flatbuffers::Offset<circle::SubGraph>> subgraphs;
- for (auto &ctx : _subgraph_contexts)
- subgraphs.push_back(buildSubGraph(ctx));
- auto model =
- circle::CreateModelDirect(_fbb, 3, &_opcodes, &subgraphs, "CircleGen generated", &_buffers);
- _fbb.Finish(model);
- return CircleBuffer{std::move(_fbb)};
-}
-
-// ===== Add Operator methods begin =====
-
-uint32_t CircleGen::addOperatorAdd(const OperatorParams &params,
- circle::ActivationFunctionType actfn)
-{
- auto options = circle::CreateAddOptions(_fbb, actfn).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_ADD,
- circle::BuiltinOptions_AddOptions, options);
-}
-
-uint32_t CircleGen::addOperatorArgMax(const OperatorParams &params, circle::TensorType output_type)
-{
- auto options = circle::CreateArgMaxOptions(_fbb, output_type).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_ARG_MAX,
- circle::BuiltinOptions_ArgMaxOptions, options);
-}
-
-uint32_t CircleGen::addOperatorAveragePool2D(const OperatorParams &params, circle::Padding padding,
- int stride_w, int stride_h, int filter_w, int filter_h,
- circle::ActivationFunctionType actfn)
-{
- auto options =
- circle::CreatePool2DOptions(_fbb, padding, stride_w, stride_h, filter_w, filter_h, actfn)
- .Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_AVERAGE_POOL_2D,
- circle::BuiltinOptions_Pool2DOptions, options);
-}
-
-uint32_t CircleGen::addOperatorCast(const OperatorParams &params, circle::TensorType input_type,
- circle::TensorType output_type)
-{
- auto options = circle::CreateCastOptions(_fbb, input_type, output_type).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_CAST,
- circle::BuiltinOptions_AddOptions, options);
-}
-
-uint32_t CircleGen::addOperatorConcatenation(const OperatorParams &params, int axis,
- circle::ActivationFunctionType actfn)
-{
- auto options = circle::CreateConcatenationOptions(_fbb, axis, actfn).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_CONCATENATION,
- circle::BuiltinOptions_ConcatenationOptions, options);
-}
-
-uint32_t CircleGen::addOperatorCos(const OperatorParams &params)
-{
- auto options = circle::CreateCosOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_COS,
- circle::BuiltinOptions_CosOptions, options);
-}
-
-uint32_t CircleGen::addOperatorEqual(const OperatorParams &params)
-{
- auto options = circle::CreateEqualOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_EQUAL,
- circle::BuiltinOptions_EqualOptions, options);
-}
-
-uint32_t CircleGen::addOperatorFullyConnected(const OperatorParams &params)
-{
- auto options = circle::CreateFullyConnectedOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_FULLY_CONNECTED,
- circle::BuiltinOptions_FullyConnectedOptions, options);
-}
-
-uint32_t CircleGen::addOperatorL2Normalization(const OperatorParams &params)
-{
- auto options = circle::CreateL2NormOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_L2_NORMALIZATION,
- circle::BuiltinOptions_L2NormOptions, options);
-}
-
-uint32_t CircleGen::addOperatorLess(const OperatorParams &params)
-{
- auto options = circle::CreateLessOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_LESS,
- circle::BuiltinOptions_LessOptions, options);
-}
-
-uint32_t CircleGen::addOperatorLeakyRelu(const OperatorParams &params, float alpha)
-{
- auto options = circle::CreateLeakyReluOptions(_fbb, alpha).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_LEAKY_RELU,
- circle::BuiltinOptions_LeakyReluOptions, options);
-}
-
-uint32_t CircleGen::addOperatorLogSoftmax(const OperatorParams &params)
-{
- auto options = circle::CreateLogSoftmaxOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_LOG_SOFTMAX,
- circle::BuiltinOptions_LogSoftmaxOptions, options);
-}
-
-uint32_t CircleGen::addOperatorNeg(const OperatorParams &params)
-{
- auto options = circle::CreatePadOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_NEG,
- circle::BuiltinOptions_NegOptions, options);
-}
-
-uint32_t CircleGen::addOperatorOneHot(const OperatorParams &params, int32_t axis)
-{
- auto options = circle::CreateOneHotOptions(_fbb, axis).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_ONE_HOT,
- circle::BuiltinOptions_OneHotOptions, options);
-}
-
-uint32_t CircleGen::addOperatorPad(const OperatorParams &params)
-{
- auto options = circle::CreatePadOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_PAD,
- circle::BuiltinOptions_PadOptions, options);
-}
-
-uint32_t CircleGen::addOperatorPadV2(const OperatorParams &params)
-{
- auto options = circle::CreatePadOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_PADV2,
- circle::BuiltinOptions_PadV2Options, options);
-}
-
-uint32_t CircleGen::addOperatorRank(const OperatorParams &params)
-{
- auto options = circle::CreateRankOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_RANK,
- circle::BuiltinOptions_RankOptions, options);
-}
-
-uint32_t CircleGen::addOperatorReshape(const OperatorParams &params, const Shape &new_shape)
-{
- auto options = circle::CreateReshapeOptionsDirect(_fbb, &new_shape).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_RESHAPE,
- circle::BuiltinOptions_ReshapeOptions, options);
-}
-
-uint32_t CircleGen::addOperatorResizeBilinear(const OperatorParams &params, bool align_corners,
- bool half_pixel_centers)
-{
- auto options =
- circle::CreateResizeBilinearOptions(_fbb, align_corners, half_pixel_centers).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_RESIZE_BILINEAR,
- circle::BuiltinOptions_ResizeBilinearOptions, options);
-}
-
-uint32_t CircleGen::addOperatorResizeNearestNeighbor(const OperatorParams &params)
-{
- auto options = circle::CreateResizeNearestNeighborOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_RESIZE_NEAREST_NEIGHBOR,
- circle::BuiltinOptions_ResizeNearestNeighborOptions, options);
-}
-
-uint32_t CircleGen::addOperatorReverseV2(const OperatorParams &params)
-{
- auto options = circle::CreateReverseV2Options(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_REVERSE_V2,
- circle::BuiltinOptions_ReverseV2Options, options);
-}
-
-uint32_t CircleGen::addOperatorSplit(const OperatorParams &params, int32_t num_split)
-{
- auto options = circle::CreateSplitOptions(_fbb, num_split).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_SPLIT,
- circle::BuiltinOptions_SplitOptions, options);
-}
-uint32_t CircleGen::addOperatorStridedSlice(const OperatorParams &params, int32_t begin_mask,
- int32_t end_mask, int32_t ellipsis_mask,
- int32_t new_axis_mask, int32_t shrink_axis_mask)
-{
- auto options = circle::CreateStridedSliceOptions(_fbb, begin_mask, end_mask, ellipsis_mask,
- new_axis_mask, shrink_axis_mask)
- .Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_STRIDED_SLICE,
- circle::BuiltinOptions_StridedSliceOptions, options);
-}
-uint32_t CircleGen::addOperatorTile(const OperatorParams &params)
-{
- auto options = circle::CreateTileOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_TILE,
- circle::BuiltinOptions_TileOptions, options);
-}
-
-uint32_t CircleGen::addOperatorWhile(const OperatorParams &params, uint32_t cond_subg,
- uint32_t body_subg)
-{
- auto options = circle::CreateWhileOptions(_fbb, cond_subg, body_subg).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_WHILE,
- circle::BuiltinOptions_WhileOptions, options);
-}
-
-uint32_t CircleGen::addOperatorIf(const OperatorParams &params, uint32_t then_subg,
- uint32_t else_subg)
-{
- auto options = circle::CreateIfOptions(_fbb, then_subg, else_subg).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_IF,
- circle::BuiltinOptions_IfOptions, options);
-}
-
-uint32_t CircleGen::addOperatorInstanceNorm(const OperatorParams &params, float epsilon,
- circle::ActivationFunctionType actfn)
-{
- auto options = circle::CreateInstanceNormOptions(_fbb, epsilon, actfn).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_INSTANCE_NORM,
- circle::BuiltinOptions_InstanceNormOptions, options);
-}
-
-uint32_t CircleGen::addOperatorTranspose(const OperatorParams &params)
-{
- auto options = circle::CreateTransposeOptions(_fbb).Union();
- return addOperatorWithOptions(params, circle::BuiltinOperator_TRANSPOSE,
- circle::BuiltinOptions_TransposeOptions, options);
-}
-
-// NOTE Please add addOperator functions ABOVE this lie
-//
-// % How to add a new addOperatorXXX fuction
-// 0. Copy code from one of the existing addOperatorXXX function
-// 1. Change the function signature (need BuiltinOperator params)
-// 2. Change enum BuiltinOperator
-// 3. Change enum BuiltinOptions
-// 4. Change CreateXXXOptions accordingly
-
-// ===== Add Operator methods end =====
-
-uint32_t CircleGen::addOperatorWithOptions(const OperatorParams &params,
- circle::BuiltinOperator opcode,
- circle::BuiltinOptions options_type,
- flatbuffers::Offset<void> options)
-{
- uint32_t opcode_ind = addOperatorCode(opcode);
- auto op = circle::CreateOperatorDirect(_fbb, opcode_ind, &params.inputs, &params.outputs,
- options_type, options);
-
- uint32_t ind = curSubgCtx().operators.size();
- curSubgCtx().operators.emplace_back(op);
- return ind;
-}
-
-uint32_t CircleGen::addOperatorCode(circle::BuiltinOperator opcode)
-{
- // TODO If the same OperatorCode is registered already, just return it
- uint32_t ind = _opcodes.size();
- _opcodes.emplace_back(circle::CreateOperatorCode(_fbb, opcode));
- return ind;
-}
-
-flatbuffers::Offset<circle::Buffer> CircleGen::buildBuffer(const uint8_t *buf, size_t size)
-{
- if (buf == nullptr && size == 0)
- return circle::CreateBuffer(_fbb);
- auto buffer = _fbb.CreateVector(buf, size);
- return circle::CreateBuffer(_fbb, buffer);
-}
-
-flatbuffers::Offset<circle::Tensor> CircleGen::buildTensor(const TensorParams &params)
-{
- auto shape = _fbb.CreateVector(params.shape);
- auto name = _fbb.CreateString(params.name);
- return circle::CreateTensor(_fbb, shape, params.tensor_type, params.buffer, name,
- 0 /* QuantParam */, false /* is_variable */, 0 /* sparsity */,
- 0 /* shape_signature */);
-}
-
-flatbuffers::Offset<circle::SparsityParameters>
-CircleGen::buildSparsityParameters(const SparsityParams &sp)
-{
- flatbuffers::Offset<flatbuffers::Vector<int32_t>> traversal_order;
- flatbuffers::Offset<flatbuffers::Vector<int32_t>> block_map;
- flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<circle::DimensionMetadata>>>
- dim_metadata;
-
- traversal_order = _fbb.CreateVector(sp.traversal_order);
- block_map = _fbb.CreateVector(sp.block_map);
-
- std::vector<flatbuffers::Offset<circle::DimensionMetadata>> dim_metadata_vec;
- for (auto &it : sp.dim_metadata)
- {
- auto fb_array_segments = circle::CreateUint16VectorDirect(_fbb, &it._array_segments.u16);
- auto fb_array_indices = circle::CreateUint16VectorDirect(_fbb, &it._array_indices.u16);
- auto dim_metadata = circle::CreateDimensionMetadata(
- _fbb, it._format, it._dense_size, it._array_segments_type, fb_array_segments.Union(),
- it._array_indices_type, fb_array_indices.Union());
- dim_metadata_vec.emplace_back(dim_metadata);
- }
- dim_metadata = _fbb.CreateVector(dim_metadata_vec);
-
- return circle::CreateSparsityParameters(_fbb, traversal_order, block_map, dim_metadata);
-}
-
-flatbuffers::Offset<circle::Tensor> CircleGen::buildTensor(const TensorParams &params,
- const SparsityParams &sp)
-{
- auto shape = _fbb.CreateVector(params.shape);
- auto name = _fbb.CreateString(params.name);
- auto sparsity = buildSparsityParameters(sp);
- return circle::CreateTensor(_fbb, shape, params.tensor_type, params.buffer, name,
- 0 /* QuantParam */, false /* is_variable */, sparsity,
- 0 /* shape_signature */);
-}
-
-flatbuffers::Offset<circle::SubGraph> CircleGen::buildSubGraph(const SubgraphContext &ctx)
-{
- return circle::CreateSubGraphDirect(_fbb, &ctx.tensors, &ctx.inputs, &ctx.outputs, &ctx.operators,
- nullptr);
-}
diff --git a/tests/nnfw_api/src/CircleGen.h b/tests/nnfw_api/src/CircleGen.h
deleted file mode 100644
index d72fb95ab..000000000
--- a/tests/nnfw_api/src/CircleGen.h
+++ /dev/null
@@ -1,199 +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 __NNFW_API_TEST_CIRCLE_GEN_H__
-#define __NNFW_API_TEST_CIRCLE_GEN_H__
-
-#include <circle_schema_generated.h>
-
-#include <vector>
-
-/**
- * @brief Class for storing flatbuffer buffer
- *
- * This is a simple wrapper for a finished FlatBufferBuilder. It owns the buffer and a user can
- * get the buffer pointer and size.
- */
-class CircleBuffer
-{
-public:
- CircleBuffer() = default;
- explicit CircleBuffer(flatbuffers::FlatBufferBuilder &&fbb) : _fbb{std::move(fbb)}
- {
- _fbb.Finished(); // The build must have been finished, so check that here
- }
-
- uint8_t *buffer() const { return _fbb.GetBufferPointer(); }
- size_t size() const { return _fbb.GetSize(); }
-
-private:
- flatbuffers::FlatBufferBuilder _fbb;
-};
-
-/**
- * @brief Circle flatbuffer file generator
- *
- * This is a helper class for generating circle file.
- *
- */
-class CircleGen
-{
-public:
- using Shape = std::vector<int32_t>;
-
- using SparseIndexVectorType = circle::SparseIndexVector;
- using SparseDimensionType = circle::DimensionType;
-
- struct SparseIndexVector
- {
- std::vector<uint16_t> u16;
- };
-
- struct DimMetaData
- {
- DimMetaData() = delete;
- DimMetaData(SparseDimensionType format, std::vector<uint16_t> array_segments,
- std::vector<uint16_t> array_indices)
- : _format{format},
- _array_segments_type(SparseIndexVectorType::SparseIndexVector_Uint16Vector),
- _array_indices_type(SparseIndexVectorType::SparseIndexVector_Uint16Vector)
- {
- _array_segments.u16 = array_segments;
- _array_indices.u16 = array_indices;
- }
- DimMetaData(SparseDimensionType format, int32_t dense_size)
- : _format{format}, _dense_size{dense_size}
- {
- }
- SparseDimensionType _format{circle::DimensionType_DENSE};
- int32_t _dense_size{0};
- SparseIndexVectorType _array_segments_type{circle::SparseIndexVector_NONE};
- SparseIndexVector _array_segments;
- SparseIndexVectorType _array_indices_type{circle::SparseIndexVector_NONE};
- SparseIndexVector _array_indices;
- };
-
- struct SparsityParams
- {
- std::vector<int32_t> traversal_order;
- std::vector<int32_t> block_map;
- std::vector<DimMetaData> dim_metadata;
- };
-
- struct TensorParams
- {
- std::vector<int32_t> shape;
- circle::TensorType tensor_type = circle::TensorType::TensorType_FLOAT32;
- uint32_t buffer = 0;
- std::string name;
- };
-
- struct OperatorParams
- {
- std::vector<int32_t> inputs;
- std::vector<int32_t> outputs;
- int version = 1;
- };
-
- struct SubgraphContext
- {
- std::vector<int> inputs;
- std::vector<int> outputs;
- std::vector<flatbuffers::Offset<circle::Tensor>> tensors;
- std::vector<flatbuffers::Offset<circle::Operator>> operators;
- };
-
-public:
- CircleGen();
-
- template <typename T> uint32_t addBuffer(const std::vector<T> &buf_vec)
- {
- auto buf = reinterpret_cast<const uint8_t *>(buf_vec.data());
- auto size = buf_vec.size() * sizeof(T);
- return addBuffer(buf, size);
- }
- uint32_t addBuffer(const uint8_t *buf, size_t size);
- uint32_t addTensor(const TensorParams &params);
- uint32_t addTensor(const TensorParams &params, const SparsityParams &sp);
- void setInputsAndOutputs(const std::vector<int> &inputs, const std::vector<int> &outputs);
- uint32_t nextSubgraph();
- CircleBuffer finish();
-
- // ===== Add Operator methods begin (SORTED IN ALPHABETICAL ORDER) =====
-
- uint32_t addOperatorAdd(const OperatorParams &params, circle::ActivationFunctionType actfn);
- uint32_t addOperatorArgMax(const OperatorParams &params,
- circle::TensorType output_type = circle::TensorType::TensorType_INT32);
- uint32_t addOperatorAveragePool2D(const OperatorParams &params, circle::Padding padding,
- int stride_w, int stride_h, int filter_w, int filter_h,
- circle::ActivationFunctionType actfn);
- uint32_t addOperatorCast(const OperatorParams &params, circle::TensorType input_type,
- circle::TensorType output_type);
- uint32_t addOperatorConcatenation(const OperatorParams &params, int axis,
- circle::ActivationFunctionType actfn);
- uint32_t addOperatorCos(const OperatorParams &params);
- uint32_t addOperatorEqual(const OperatorParams &params);
- uint32_t addOperatorFullyConnected(const OperatorParams &params);
- uint32_t addOperatorIf(const OperatorParams &params, uint32_t then_subg, uint32_t else_subg);
- uint32_t addOperatorInstanceNorm(const OperatorParams &params, float epsilon,
- circle::ActivationFunctionType actfn);
- uint32_t addOperatorL2Normalization(const OperatorParams &params);
- uint32_t addOperatorLeakyRelu(const OperatorParams &params, float alpha);
- uint32_t addOperatorLess(const OperatorParams &params);
- uint32_t addOperatorLogSoftmax(const OperatorParams &params);
- uint32_t addOperatorNeg(const OperatorParams &params);
- uint32_t addOperatorOneHot(const OperatorParams &params, int32_t axis);
- uint32_t addOperatorPad(const OperatorParams &params);
- uint32_t addOperatorPadV2(const OperatorParams &params);
- uint32_t addOperatorRank(const OperatorParams &params);
- uint32_t addOperatorReshape(const OperatorParams &params, const Shape &new_shape);
- uint32_t addOperatorResizeBilinear(const OperatorParams &params, bool align_corners = false,
- bool half_pixel_centers = false);
- uint32_t addOperatorResizeNearestNeighbor(const OperatorParams &params);
- uint32_t addOperatorReverseV2(const OperatorParams &params);
- uint32_t addOperatorSplit(const OperatorParams &params, int32_t num_split);
- uint32_t addOperatorStridedSlice(const OperatorParams &params, int32_t begin_mask = 0,
- int32_t end_mask = 0, int32_t ellipsis_mask = 0,
- int32_t new_axis_mask = 0, int32_t shrink_axis_mask = 0);
- uint32_t addOperatorTile(const OperatorParams &params);
- uint32_t addOperatorTranspose(const OperatorParams &params);
- uint32_t addOperatorWhile(const OperatorParams &params, uint32_t cond_subg, uint32_t body_subg);
-
- // NOTE Please add addOperator functions ABOVE this line in ALPHABETICAL ORDER
- // ===== Add Operator methods end =====
-
-private:
- uint32_t addOperatorWithOptions(const OperatorParams &params, circle::BuiltinOperator opcode,
- circle::BuiltinOptions options_type,
- flatbuffers::Offset<void> options);
- uint32_t addOperatorCode(circle::BuiltinOperator opcode);
- flatbuffers::Offset<circle::Buffer> buildBuffer(const uint8_t *buf, size_t size);
- flatbuffers::Offset<circle::Tensor> buildTensor(const TensorParams &params);
- flatbuffers::Offset<circle::SparsityParameters> buildSparsityParameters(const SparsityParams &sp);
- flatbuffers::Offset<circle::Tensor> buildTensor(const TensorParams &params,
- const SparsityParams &sp);
- flatbuffers::Offset<circle::SubGraph> buildSubGraph(const SubgraphContext &ctx);
-
- SubgraphContext &curSubgCtx() { return _subgraph_contexts.back(); }
-
-private:
- flatbuffers::FlatBufferBuilder _fbb{1024};
- std::vector<flatbuffers::Offset<circle::Buffer>> _buffers;
- std::vector<flatbuffers::Offset<circle::OperatorCode>> _opcodes;
- std::vector<SubgraphContext> _subgraph_contexts;
-};
-
-#endif // __NNFW_API_TEST_CIRCLE_GEN_H__
diff --git a/tests/nnfw_api/src/GenModelTest.h b/tests/nnfw_api/src/GenModelTest.h
deleted file mode 100644
index a4c67a863..000000000
--- a/tests/nnfw_api/src/GenModelTest.h
+++ /dev/null
@@ -1,436 +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.
- */
-
-#include <gtest/gtest.h>
-#include <nnfw_internal.h>
-
-#include <fstream>
-#include <string>
-#include <unordered_map>
-
-#include "CircleGen.h"
-#include "fixtures.h"
-
-inline size_t sizeOfNnfwType(NNFW_TYPE type)
-{
- switch (type)
- {
- case NNFW_TYPE_TENSOR_BOOL:
- case NNFW_TYPE_TENSOR_UINT8:
- case NNFW_TYPE_TENSOR_QUANT8_ASYMM:
- return 1;
- case NNFW_TYPE_TENSOR_FLOAT32:
- case NNFW_TYPE_TENSOR_INT32:
- return 4;
- case NNFW_TYPE_TENSOR_INT64:
- return 8;
- default:
- throw std::runtime_error{"Invalid tensor type"};
- }
-}
-
-// TODO Unify this with `SessionObject` in `fixtures.h`
-struct SessionObjectGeneric
-{
- nnfw_session *session = nullptr;
- std::vector<std::vector<uint8_t>> inputs;
- std::vector<std::vector<uint8_t>> outputs;
-};
-
-struct TestCaseData
-{
- /**
- * @brief A vector of input buffers
- */
- std::vector<std::vector<uint8_t>> inputs;
-
- /**
- * @brief A vector of output buffers
- */
- std::vector<std::vector<uint8_t>> outputs;
-
- /**
- * @brief Append vector data to inputs
- *
- * @tparam T Data type
- * @param data vector data array
- */
- template <typename T> void addInput(const std::vector<T> &data) { addData(inputs, data); }
-
- /**
- * @brief Append vector data to inputs
- *
- * @tparam T Data type
- * @param data vector data array
- */
- template <typename T> void addOutput(const std::vector<T> &data) { addData(outputs, data); }
-
- /**
- * @brief Set @c True if @c NNFW_STATUS_ERROR is expected after calling @c nnfw_run() with
- * this test case; set @c False otherwise.
- */
- void expect_error_on_run(bool expect_error_on_run) { _expect_error_on_run = expect_error_on_run; }
- bool expect_error_on_run() const { return _expect_error_on_run; }
-
-private:
- template <typename T>
- static void addData(std::vector<std::vector<uint8_t>> &dest, const std::vector<T> &data)
- {
- size_t size = data.size() * sizeof(T);
- dest.emplace_back();
- dest.back().resize(size);
- std::memcpy(dest.back().data(), data.data(), size);
- }
-
- bool _expect_error_on_run = false;
-};
-
-template <>
-inline void TestCaseData::addData<bool>(std::vector<std::vector<uint8_t>> &dest,
- const std::vector<bool> &data)
-{
- size_t size = data.size() * sizeof(uint8_t);
- dest.emplace_back();
- dest.back().resize(size);
- std::transform(data.cbegin(), data.cend(), dest.back().data(),
- [](bool b) { return static_cast<uint8_t>(b); });
-}
-
-/**
- * @brief Create a TestCaseData with a uniform type
- *
- * A helper function for generating test cases that has the same data type for model inputs/outputs.
- *
- * @tparam T Uniform tensor type
- * @param inputs Inputs tensor buffers
- * @param outputs Output tensor buffers
- * @return TestCaseData Generated test case data
- */
-template <typename T>
-static TestCaseData uniformTCD(const std::vector<std::vector<T>> &inputs,
- const std::vector<std::vector<T>> &outputs)
-{
- TestCaseData ret;
- for (const auto &data : inputs)
- ret.addInput(data);
- for (const auto &data : outputs)
- ret.addOutput(data);
- return ret;
-}
-
-/**
- * @brief A test configuration class
- */
-class GenModelTestContext
-{
-public:
- GenModelTestContext(CircleBuffer &&cbuf) : _cbuf{std::move(cbuf)}, _backends{"cpu"} {}
-
- /**
- * @brief Return circle buffer
- *
- * @return CircleBuffer& the circle buffer
- */
- const CircleBuffer &cbuf() const { return _cbuf; }
-
- /**
- * @brief Return test cases
- *
- * @return std::vector<TestCaseData>& the test cases
- */
- const std::vector<TestCaseData> &test_cases() const { return _test_cases; }
-
- /**
- * @brief Return backends
- *
- * @return const std::vector<std::string>& the backends to be tested
- */
- const std::vector<std::string> &backends() const { return _backends; }
-
- /**
- * @brief Return test is defined to fail on model load
- *
- * @return bool test is defined to fail on model load
- */
- bool expected_fail_model_load() const { return _expected_fail_model_load; }
-
- /**
- * @brief Return test is defined to fail on compile
- *
- * @return bool test is defined to fail on compile
- */
- bool expected_fail_compile() const { return _expected_fail_compile; }
-
- /**
- * @brief Set the output buffer size of specified output tensor
- * Note that output tensor size of a model with dynamic tensor is calculated while
- * running the model.
- * Therefore, before runniing the model, the sufficient size of buffer should
- * be prepared by calling this method.
- * The size does not need to be the exact size.
- */
- void output_sizes(uint32_t ind, size_t size) { _output_sizes[ind] = size; }
-
- size_t output_sizes(uint32_t ind) const { return _output_sizes.at(ind); }
-
- bool hasOutputSizes(uint32_t ind) const { return _output_sizes.find(ind) != _output_sizes.end(); }
-
- /**
- * @brief Add a test case
- *
- * @param tc the test case to be added
- */
- void addTestCase(const TestCaseData &tc) { _test_cases.emplace_back(tc); }
-
- /**
- * @brief Add a test case
- *
- * @param tc the test case to be added
- */
- void setBackends(const std::vector<std::string> &backends)
- {
- _backends.clear();
-
- for (auto backend : backends)
- {
-#ifdef TEST_ACL_BACKEND
- if (backend == "acl_cl" || backend == "acl_neon")
- {
- _backends.push_back(backend);
- }
-#endif
- if (backend == "cpu")
- {
- _backends.push_back(backend);
- }
- }
- }
-
- /**
- * @brief Expect failure while model load
- */
- void expectFailModelLoad() { _expected_fail_model_load = true; }
-
- /**
- * @brief Expect failure while compiling
- */
- void expectFailCompile() { _expected_fail_compile = true; }
-
-private:
- CircleBuffer _cbuf;
- std::vector<TestCaseData> _test_cases;
- std::vector<std::string> _backends;
- std::unordered_map<uint32_t, size_t> _output_sizes;
- bool _expected_fail_model_load{false};
- bool _expected_fail_compile{false};
-};
-
-/**
- * @brief Generated Model test fixture for a one time inference
- *
- * This fixture is for one-time inference test with variety of generated models.
- * It is the test maker's responsiblity to create @c _context which contains
- * test body, which are generated circle buffer, model input data and output data and
- * backend list to be tested.
- * The rest(calling API functions for execution) is done by @c Setup and @c TearDown .
- *
- */
-class GenModelTest : public ::testing::Test
-{
-protected:
- void SetUp() override
- { // DO NOTHING
- }
-
- void TearDown() override
- {
- for (std::string backend : _context->backends())
- {
- // NOTE If we can prepare many times for one model loading on same session,
- // we can move nnfw_create_session to SetUp and
- // nnfw_load_circle_from_buffer to outside forloop
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&_so.session));
- auto &cbuf = _context->cbuf();
- auto model_load_result =
- nnfw_load_circle_from_buffer(_so.session, cbuf.buffer(), cbuf.size());
- if (_context->expected_fail_model_load())
- {
- ASSERT_NE(model_load_result, NNFW_STATUS_NO_ERROR);
- std::cerr << "Failed model loading as expected." << std::endl;
- NNFW_ENSURE_SUCCESS(nnfw_close_session(_so.session));
- continue;
- }
- NNFW_ENSURE_SUCCESS(model_load_result);
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(_so.session, backend.data()));
-
- if (_context->expected_fail_compile())
- {
- ASSERT_EQ(nnfw_prepare(_so.session), NNFW_STATUS_ERROR);
-
- NNFW_ENSURE_SUCCESS(nnfw_close_session(_so.session));
- continue;
- }
- NNFW_ENSURE_SUCCESS(nnfw_prepare(_so.session));
-
- // In/Out buffer settings
- uint32_t num_inputs;
- NNFW_ENSURE_SUCCESS(nnfw_input_size(_so.session, &num_inputs));
- _so.inputs.resize(num_inputs);
- for (uint32_t ind = 0; ind < _so.inputs.size(); ind++)
- {
- nnfw_tensorinfo ti;
- NNFW_ENSURE_SUCCESS(nnfw_input_tensorinfo(_so.session, ind, &ti));
- uint64_t input_elements = num_elems(&ti);
- _so.inputs[ind].resize(input_elements * sizeOfNnfwType(ti.dtype));
- if (_so.inputs[ind].size() == 0)
- {
- // Optional inputs
- ASSERT_EQ(nnfw_set_input(_so.session, ind, ti.dtype, nullptr, 0), NNFW_STATUS_NO_ERROR);
- }
- else
- {
- ASSERT_EQ(nnfw_set_input(_so.session, ind, ti.dtype, _so.inputs[ind].data(),
- _so.inputs[ind].size()),
- NNFW_STATUS_NO_ERROR);
- }
- }
-
- uint32_t num_outputs;
- NNFW_ENSURE_SUCCESS(nnfw_output_size(_so.session, &num_outputs));
- _so.outputs.resize(num_outputs);
- for (uint32_t ind = 0; ind < _so.outputs.size(); ind++)
- {
- nnfw_tensorinfo ti;
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(_so.session, ind, &ti));
-
- auto size = 0;
- {
- if (_context->hasOutputSizes(ind))
- {
- size = _context->output_sizes(ind);
- }
- else
- {
- uint64_t output_elements = num_elems(&ti);
- size = output_elements * sizeOfNnfwType(ti.dtype);
- }
- _so.outputs[ind].resize(size);
- }
-
- ASSERT_GT(_so.outputs[ind].size(), 0) << "Please make sure TC output is non-empty.";
- ASSERT_EQ(nnfw_set_output(_so.session, ind, ti.dtype, _so.outputs[ind].data(),
- _so.outputs[ind].size()),
- NNFW_STATUS_NO_ERROR);
- }
-
- // Set input values, run, and check output values
- for (auto &test_case : _context->test_cases())
- {
- auto &ref_inputs = test_case.inputs;
- auto &ref_outputs = test_case.outputs;
- ASSERT_EQ(_so.inputs.size(), ref_inputs.size());
- for (uint32_t i = 0; i < _so.inputs.size(); i++)
- {
- // Fill the values
- ASSERT_EQ(_so.inputs[i].size(), ref_inputs[i].size());
- memcpy(_so.inputs[i].data(), ref_inputs[i].data(), ref_inputs[i].size());
- }
-
- if (test_case.expect_error_on_run())
- {
- ASSERT_EQ(nnfw_run(_so.session), NNFW_STATUS_ERROR);
- continue;
- }
-
- NNFW_ENSURE_SUCCESS(nnfw_run(_so.session));
-
- ASSERT_EQ(_so.outputs.size(), ref_outputs.size());
- for (uint32_t i = 0; i < _so.outputs.size(); i++)
- {
- nnfw_tensorinfo ti;
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(_so.session, i, &ti));
-
- // Check output tensor values
- auto &ref_output = ref_outputs[i];
- auto &output = _so.outputs[i];
- ASSERT_EQ(output.size(), ref_output.size());
-
- switch (ti.dtype)
- {
- case NNFW_TYPE_TENSOR_BOOL:
- compareBuffersExactBool(ref_output, output, i);
- break;
- case NNFW_TYPE_TENSOR_UINT8:
- compareBuffersExact<uint8_t>(ref_output, output, i);
- break;
- case NNFW_TYPE_TENSOR_INT32:
- compareBuffersExact<int32_t>(ref_output, output, i);
- break;
- case NNFW_TYPE_TENSOR_FLOAT32:
- // TODO better way for handling FP error?
- for (uint32_t e = 0; e < ref_output.size() / sizeof(float); e++)
- {
- float refval = reinterpret_cast<const float *>(ref_output.data())[e];
- float val = reinterpret_cast<const float *>(output.data())[e];
- EXPECT_NEAR(refval, val, 0.001) << "Output #" << i << ", Element Index : " << e;
- }
- break;
- case NNFW_TYPE_TENSOR_INT64:
- compareBuffersExact<int64_t>(ref_output, output, i);
- break;
- case NNFW_TYPE_TENSOR_QUANT8_ASYMM:
- throw std::runtime_error{"NYI : comparison of tensors of QUANT8_ASYMM"};
- default:
- throw std::runtime_error{"Invalid tensor type"};
- }
- // TODO Add shape comparison
- }
- }
-
- NNFW_ENSURE_SUCCESS(nnfw_close_session(_so.session));
- }
- }
-
-private:
- template <typename T>
- void compareBuffersExact(const std::vector<uint8_t> &ref_buf, const std::vector<uint8_t> &act_buf,
- uint32_t index)
- {
- for (uint32_t e = 0; e < ref_buf.size() / sizeof(T); e++)
- {
- T ref = reinterpret_cast<const T *>(ref_buf.data())[e];
- T act = reinterpret_cast<const T *>(act_buf.data())[e];
- EXPECT_EQ(ref, act) << "Output #" << index << ", Element Index : " << e;
- }
- }
-
- void compareBuffersExactBool(const std::vector<uint8_t> &ref_buf,
- const std::vector<uint8_t> &act_buf, uint32_t index)
- {
- for (uint32_t e = 0; e < ref_buf.size() / sizeof(uint8_t); e++)
- {
- uint8_t ref_raw = reinterpret_cast<const uint8_t *>(ref_buf.data())[e];
- bool ref = (ref_raw != 0 ? true : false);
- uint8_t act_raw = reinterpret_cast<const uint8_t *>(act_buf.data())[e];
- bool act = (act_raw != 0 ? true : false);
- EXPECT_EQ(ref, act) << "Output #" << index << ", Element Index : " << e;
- }
- }
-
-protected:
- SessionObjectGeneric _so;
- std::unique_ptr<GenModelTestContext> _context;
-};
diff --git a/tests/nnfw_api/src/GenModelTests.cc b/tests/nnfw_api/src/GenModelTests.cc
deleted file mode 100644
index 538da5dfa..000000000
--- a/tests/nnfw_api/src/GenModelTests.cc
+++ /dev/null
@@ -1,195 +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.
- */
-
-/**
- * @file This file contains miscellaneous GenModelTest test cases.
- *
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, UnusedConstOutputOnly)
-{
- // A single tensor which is constant
- CircleGen cgen;
- uint32_t const_buf = cgen.addBuffer(std::vector<float>{9, 8, 7, 6});
- int out_const = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32, const_buf});
- cgen.setInputsAndOutputs({}, {out_const});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({}, {{9, 8, 7, 6}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, UnusedConstOutputAndAdd)
-{
- // A single tensor which is constant + an Add op
- CircleGen cgen;
- uint32_t rhs_buf = cgen.addBuffer(std::vector<float>{5, 4, 7, 4});
- uint32_t const_buf = cgen.addBuffer(std::vector<float>{9, 8, 7, 6});
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32, rhs_buf});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out_const = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32, const_buf});
- cgen.addOperatorAdd({{lhs, rhs}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({lhs}, {out, out_const});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 3, 2, 4}}, {{6, 7, 9, 8}, {9, 8, 7, 6}}));
- _context->addTestCase(uniformTCD<float>({{0, 1, 2, 3}}, {{5, 5, 9, 7}, {9, 8, 7, 6}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, UsedConstOutput)
-{
- // (( Input 1 )) ---------\
- // |=> [ Add ] -> (( Output 1 ))
- // (( Const Output 2 )) --<
- // |=> [ Add ] -> (( Output 0 ))
- // (( Input 0 )) ---------/
- CircleGen cgen;
- uint32_t rhs_buf = cgen.addBuffer(std::vector<float>{6, 4, 8, 1});
- int in0 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int in1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out0 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int const_out2 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32, rhs_buf});
- cgen.addOperatorAdd({{in0, const_out2}, {out0}}, circle::ActivationFunctionType_NONE);
- cgen.addOperatorAdd({{const_out2, in1}, {out1}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in0, in1}, {out0, out1, const_out2});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 1, 1, 1}, {-1, -1, -1, -1}},
- {{7, 5, 9, 2}, {5, 3, 7, 0}, {6, 4, 8, 1}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, TensorBothInputOutput)
-{
- // A single tensor which is an input and an output at the same time
- CircleGen cgen;
- int t = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_FLOAT32});
- cgen.setInputsAndOutputs({t}, {t});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 3, 2, 4}}, {{1, 3, 2, 4}}));
- _context->addTestCase(uniformTCD<float>({{100, 300, 200, 400}}, {{100, 300, 200, 400}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, TensorBothInputOutputCrossed)
-{
- // Two tensors which are an input and an output at the same time
- // But the order of inputs and outputs is changed.
- CircleGen cgen;
- int t1 = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int t2 = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- cgen.setInputsAndOutputs({t1, t2}, {t2, t1});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1}, {2}}, {{2}, {1}}));
- _context->addTestCase(uniformTCD<float>({{100}, {200}}, {{200}, {100}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneTensor_TwoOutputs)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{2}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{2}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{2}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{lhs, rhs}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({lhs, rhs}, {out, out}); // Same tensors are used twice as output
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 1}, {2, 2}}, {{3, 3}, {3, 3}}));
- _context->addTestCase(uniformTCD<float>({{2, 4}, {7, 4}}, {{9, 8}, {9, 8}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneTensor_ThreeOutputs)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{lhs, rhs}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({lhs, rhs}, {out, out, out}); // Same tensors are used 3 times as output
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1}, {2}}, {{3}, {3}, {3}}));
- _context->addTestCase(uniformTCD<float>({{2}, {7}}, {{9}, {9}, {9}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneTensor_InputAndTwoOutputs)
-{
- CircleGen cgen;
- int t = cgen.addTensor({{2}, circle::TensorType::TensorType_FLOAT32});
- cgen.setInputsAndOutputs({t}, {t, t}); // Same tensor is an input and 2 outputs
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 1}}, {{1, 1}, {1, 1}}));
- _context->addTestCase(uniformTCD<float>({{2, 4}}, {{2, 4}, {2, 4}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneTensor_InputAndTwoOutputsUsed)
-{
- CircleGen cgen;
- int t = cgen.addTensor({{2}, circle::TensorType::TensorType_FLOAT32});
- int o = cgen.addTensor({{2}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorNeg({{t}, {o}});
- cgen.setInputsAndOutputs({t}, {t, t, o}); // Same tensor is an input and 2 outputs
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 1}}, {{1, 1}, {1, 1}, {-1, -1}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneTensor_ConstAndThreeOutputs)
-{
- CircleGen cgen;
- uint32_t const_buf = cgen.addBuffer(std::vector<float>{2, 5});
- int t = cgen.addTensor({{2}, circle::TensorType_FLOAT32, const_buf});
- cgen.setInputsAndOutputs({}, {t, t, t}); // A const tensor is 3 outputs
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({}, {{2, 5}, {2, 5}, {2, 5}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/ModelTestDynamicTensor.cc b/tests/nnfw_api/src/ModelTestDynamicTensor.cc
deleted file mode 100644
index 9a3a1add0..000000000
--- a/tests/nnfw_api/src/ModelTestDynamicTensor.cc
+++ /dev/null
@@ -1,516 +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.
- */
-
-#include <gtest/gtest.h>
-#include <nnfw_internal.h>
-
-#include "common.h"
-#include "fixtures.h"
-#include "CircleGen.h"
-#include "GenModelTest.h"
-
-void set_input_output(nnfw_session *session, const std::vector<float> &input,
- std::vector<float> &actual_output)
-{
- ASSERT_EQ(nnfw_set_input(session, 0, NNFW_TYPE_TENSOR_FLOAT32, input.data(),
- sizeof(float) * input.size()),
- NNFW_STATUS_NO_ERROR);
-
- ASSERT_EQ(nnfw_set_output(session, 0, NNFW_TYPE_TENSOR_FLOAT32, actual_output.data(),
- sizeof(float) * actual_output.size()),
- NNFW_STATUS_NO_ERROR);
-}
-
-void set_input_output(nnfw_session *session, const std::vector<float> &input0,
- const std::vector<float> &input1, std::vector<float> &actual_output)
-{
- ASSERT_EQ(nnfw_set_input(session, 0, NNFW_TYPE_TENSOR_FLOAT32, input0.data(),
- sizeof(float) * input0.size()),
- NNFW_STATUS_NO_ERROR);
- ASSERT_EQ(nnfw_set_input(session, 1, NNFW_TYPE_TENSOR_FLOAT32, input1.data(),
- sizeof(float) * input1.size()),
- NNFW_STATUS_NO_ERROR);
-
- ASSERT_EQ(nnfw_set_output(session, 0, NNFW_TYPE_TENSOR_FLOAT32, actual_output.data(),
- sizeof(float) * actual_output.size()),
- NNFW_STATUS_NO_ERROR);
-}
-
-/**
- * @brief Testing the following model:
- *
- * Testing the following model:
- * #1 = const(value = [-1.5, -1.0, -0.5, 0.5, 1.0, 1.5], shape=[2, 3])
- * #2 = placeholder (shape = [2]) <-------- this is an input
- * #3 = reshape(#1, #2)
- *
- * @note Run this test with "cpu" backend
- */
-auto build_dynamic_Reshape()
-{
- CircleGen cgen;
-
- auto f32 = circle::TensorType::TensorType_FLOAT32;
- auto i32 = circle::TensorType::TensorType_INT32;
-
- std::vector<float> new_shape_data{-1.5, -1.0, -0.5, 0.5, 1.0, 1.5};
- uint32_t input_buf = cgen.addBuffer(new_shape_data); // shape = [2, 3]
- int input = cgen.addTensor({{2, 3}, f32, input_buf});
- int new_shape = cgen.addTensor({{2}, i32});
- int out = cgen.addTensor({{}, f32}); // scalar, meaning output shape is unspecified
-
- CircleGen::Shape empty_new_shape;
- cgen.addOperatorReshape({{input, new_shape}, {out}}, empty_new_shape);
- cgen.setInputsAndOutputs({new_shape}, {out});
- auto cbuf = cgen.finish();
- return cbuf;
-}
-
-TEST_F(GenModelTest, dynamic_reshape_from_2x3_to_3x2)
-{
- const std::vector<int> new_shape{3, 2};
- const std::vector<float> expected{-1.5, -1.0, -0.5, 0.5, 1.0, 1.5};
-
- _context = std::make_unique<GenModelTestContext>(build_dynamic_Reshape());
- {
- TestCaseData tcd;
- tcd.addInput(new_shape);
- tcd.addOutput(expected);
- _context->addTestCase(tcd);
- _context->setBackends({"cpu"}); // Currently, dynamic tensor runs on "cpu" only
- _context->output_sizes(0, sizeof(float) * expected.size());
- }
- // GenModelTest::teardown() will do the rest
- SUCCEED();
-}
-
-/**
- * @brief Negative test.
- * Reshape's first input has 6 values but trying to reshaping to [3, 3]
- */
-TEST_F(GenModelTest, neg_reshape_from_2x3_to_wrong_3x3)
-{
- const std::vector<int> wrong_shape{3, 3}; // wrong shape input
- const std::vector<float> expected{0}; // whatever
-
- _context = std::make_unique<GenModelTestContext>(build_dynamic_Reshape());
- {
- TestCaseData tcd;
- tcd.addInput(wrong_shape);
- tcd.addOutput(expected);
- tcd.expect_error_on_run(true);
-
- _context->addTestCase(tcd);
- _context->setBackends({"cpu"}); // Currently, dynamic tensor runs on "cpu" only
- _context->output_sizes(0, sizeof(float) * expected.size());
- }
- // GenModelTest::teardown() will do the rest
- SUCCEED();
-}
-
-TEST_F(GenModelTest, reshape_multiple_executions)
-{
- std::vector<int> new_shape;
- std::vector<float> expected = {-1.5, -1.0, -0.5, 0.5, 1.0, 1.5};
-
- auto add_tcd = [&](const decltype(new_shape) &&new_shape) {
- TestCaseData tcd;
- tcd.addInput(new_shape);
- tcd.addOutput(expected);
- _context->addTestCase(tcd);
- };
-
- _context = std::make_unique<GenModelTestContext>(build_dynamic_Reshape());
- {
- add_tcd({3, 2});
- add_tcd({1, 6});
- add_tcd({6, 1});
-
- _context->setBackends({"cpu"}); // Currently, dynamic tensor runs on "cpu" only
- _context->output_sizes(0, sizeof(float) * expected.size());
- }
- // GenModelTest::teardown() will do the rest
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_reshape_multiple_executions)
-{
- std::vector<int> new_shape;
- std::vector<float> expected = {-1.5, -1.0, -0.5, 0.5, 1.0, 1.5};
-
- auto add_tcd = [&](const decltype(new_shape) &&new_shape, bool expect_error_on_run) {
- TestCaseData tcd;
- tcd.addInput(new_shape);
- tcd.addOutput(expected);
- tcd.expect_error_on_run(expect_error_on_run);
- _context->addTestCase(tcd);
- };
-
- _context = std::make_unique<GenModelTestContext>(build_dynamic_Reshape());
- {
- bool EXPECT_ERROR_ON_RUN = true;
- bool EXPECT_SUCCESS_ON_RUN = !EXPECT_ERROR_ON_RUN;
-
- add_tcd({3, 2}, EXPECT_SUCCESS_ON_RUN);
- add_tcd({1, 100}, EXPECT_ERROR_ON_RUN); // 1th tcd. wrong shape
- add_tcd({6, 1}, EXPECT_SUCCESS_ON_RUN);
-
- _context->setBackends({"cpu"}); // Currently, dynamic tensor runs on "cpu" only
- _context->output_sizes(0, sizeof(float) * expected.size());
- }
- // GenModelTest::teardown() will do the rest
- SUCCEED();
-}
-
-//
-// Unknown Dimension Test
-// Trying to set unknown dim to other value before calling nnfw_prepare()
-//
-
-/**
- * @brief Testing the following model:
- *
- * #0 = placeholder([None, None]) # initially, shape is [1, 1]
- * #1 = placeholder([2, 3])
- * #2 = concat (#0, #1, axis=0)
- *
- * Calling sequence:
- * - nnfw_set_input_tensorinfo(#0, [1, 3]) # now, [1, 3]
- * - nnfw_prepare() # this should work
- * - nnfw_set_input()
- * - nnfw_run()
- *
- * @note Run this test with "cpu" backend
- */
-auto build_model_buf_Concatenation_unknwon_dims()
-{
- // Model is not important
- CircleGen cgen;
- auto f32 = circle::TensorType::TensorType_FLOAT32;
- int in1 = cgen.addTensor({{1, 1}, f32}); // consider this [None, None]
- int in2 = cgen.addTensor({{2, 3}, f32});
- int out = cgen.addTensor({{}, f32}); // scalar, meaning output shape is unspecified
- cgen.addOperatorConcatenation({{in1, in2}, {out}}, 0, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in1, in2}, {out});
- auto cbuf = cgen.finish();
- return cbuf;
-}
-
-TEST(TestDynamicTensor, concat_unknown_dim_input0_to_2x3)
-{
- nnfw_session *session = nullptr;
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&session));
- const auto model_buf = build_model_buf_Concatenation_unknwon_dims();
- NNFW_ENSURE_SUCCESS(nnfw_load_circle_from_buffer(session, model_buf.buffer(), model_buf.size()));
-
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(session, "cpu"));
-
- const std::vector<float> input0 = {1, 2, 3}; // of shape [1, 3]
- const std::vector<float> input1 = {4, 5, 6, 7, 8, 9}; // of shape [2, 3]
-
- const std::vector<float> expected = {1, 2, 3, 4, 5, 6, 7, 8, 9};
- std::vector<float> actual_output(expected.size());
-
- // input reshaping to [1, 3]
- nnfw_tensorinfo ti = {NNFW_TYPE_TENSOR_FLOAT32, 2, {1, 3}};
- NNFW_ENSURE_SUCCESS(nnfw_set_input_tensorinfo(session, 0, &ti));
- NNFW_ENSURE_SUCCESS(nnfw_prepare(session));
-
- set_input_output(session, input0, input1, actual_output);
-
- // Do inference
- NNFW_STATUS res = nnfw_run(session);
- NNFW_ENSURE_SUCCESS(res);
-
- // output value check
- for (int i = 0; i < expected.size(); ++i)
- ASSERT_EQ(expected[i], actual_output[i]);
-}
-
-/**
- * @brief Negative Test: Testing the following model:
- *
- * #0 = placeholder([None, None]) # initially, [1, 1]
- * #1 = placeholder([2, 3])
- * #2 = concat (#0, #1, axis=0)
- *
- * Calling sequence:
- * - nnfw_set_input tensorinfo(#0, [3, 1]) # now [3, 1]
- * - nnfw_prepare() # should fail (shape mismatch)
- * - nnfw_set_input()
- * - nnfw_run()
- *
- * @note Run this test with "cpu" backend and "linear" executor
- */
-TEST(TestDynamicTensor, neg_concat_input0_to_wrong_shape)
-{
- nnfw_session *session = nullptr;
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&session));
- const auto model_buf = build_model_buf_Concatenation_unknwon_dims();
- NNFW_ENSURE_SUCCESS(nnfw_load_circle_from_buffer(session, model_buf.buffer(), model_buf.size()));
-
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(session, "cpu"));
-
- const std::vector<float> input0 = {1, 2, 3}; // of shape [3, 1], wrong shape
- const std::vector<float> input1 = {4, 5, 6, 7, 8, 9}; // of shape [2, 3]
-
- std::vector<float> actual_output(100); // whatever size
-
- // input reshaping to [3, 1]
- nnfw_tensorinfo ti = {NNFW_TYPE_TENSOR_FLOAT32, 2, {3, 1}};
- NNFW_ENSURE_SUCCESS(nnfw_set_input_tensorinfo(session, 0, &ti));
-
- ASSERT_EQ(nnfw_prepare(session), NNFW_STATUS_ERROR);
-}
-
-//
-// test about calling nnfw_set_input_tensorinfo() after compilation
-//
-
-/**
- * @brief Testing the following model, which has a binary operation:
- *
- * #0 = placeholder([])
- * #1 = placeholder([1, 2, 3])
- * #2 = add (#0, #1)
- * #3 = add (#2, #2)
- *
- * Calling sequence:
- * - nnfw_prepare()
- * - nnfw_set_input_tensorinfo(#0, [2, 2, 3]) // This will make #3 tensor's shape [2, 2, 3]
- * - nnfw_set_input()
- * - nnfw_run()
- *
- * @note Run this test with "cpu" backend
- */
-auto build_model_buf_Add_unspecified_rank()
-{
- // Model is not important
- CircleGen cgen;
- auto f32 = circle::TensorType::TensorType_FLOAT32;
- int in1 = cgen.addTensor({{}, f32}); // scalar, meaning shape is unspecified
- int in2 = cgen.addTensor({{1, 2, 3}, f32});
- int op_out = cgen.addTensor({{}, f32}); // unspecified
- int out = cgen.addTensor({{}, f32}); // unspecified
- cgen.addOperatorAdd({{in1, in2}, {op_out}}, circle::ActivationFunctionType_NONE);
- cgen.addOperatorAdd({{op_out, op_out}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in1, in2}, {out});
- auto cbuf = cgen.finish();
- return cbuf;
-}
-
-TEST(TestDynamicTensor, set_input_tensorinfo_after_compilation_add)
-{
- nnfw_session *session = nullptr;
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&session));
- const auto model_buf = build_model_buf_Add_unspecified_rank();
- NNFW_ENSURE_SUCCESS(nnfw_load_circle_from_buffer(session, model_buf.buffer(), model_buf.size()));
-
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(session, "cpu"));
-
- // input reshaping to [2, 2, 3]
- nnfw_tensorinfo input0_ti = {NNFW_TYPE_TENSOR_FLOAT32, 3, {2, 2, 3}};
-
- std::vector<float> input0 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
- std::vector<float> input1 = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1};
- std::vector<float> actual_output(12);
- std::vector<float> expected_output = {1.1 * 2, 2.1 * 2, 3.1 * 2, 4.1 * 2, 5.1 * 2, 6.1 * 2,
- 7.1 * 2, 8.1 * 2, 9.1 * 2, 10.1 * 2, 11.1 * 2, 12.1 * 2};
-
- NNFW_ENSURE_SUCCESS(nnfw_prepare(session));
-
- NNFW_ENSURE_SUCCESS(nnfw_set_input_tensorinfo(session, 0, &input0_ti));
-
- set_input_output(session, input0, input1, actual_output);
-
- // Do inference
- NNFW_STATUS res = nnfw_run(session);
- NNFW_ENSURE_SUCCESS(res);
-
- // output value check
- for (int i = 0; i < expected_output.size(); ++i)
- ASSERT_EQ(expected_output[i], actual_output[i]);
-}
-
-/**
- * @brief Testing the following model, which has a unary operation:
- *
- * #0 = placeholder(shape = [4, 4])
- * #1 = neg (#0)
- *
- * Calling sequence:
- * - nnfw_prepare()
- * - nnfw_set_input_tensorinfo(#0, [20, 50])
- * - nnfw_set_input()
- * - nnfw_run()
- *
- * @note Run this test with "cpu" backend
- */
-
-auto build_model_buf_NEG()
-{
- // Model is not important
- CircleGen cgen;
- int in = cgen.addTensor({{4, 4}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{4, 4}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorNeg({{in}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
- auto cbuf = cgen.finish();
- return cbuf;
-}
-
-TEST(TestDynamicTensor, set_input_tensorinfo_after_compilation_neg)
-{
- nnfw_session *session = nullptr;
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&session));
- const auto model_buf = build_model_buf_NEG();
- nnfw_load_circle_from_buffer(session, model_buf.buffer(), model_buf.size());
-
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(session, "cpu"));
-
- nnfw_tensorinfo input0_ti_original = {NNFW_TYPE_TENSOR_FLOAT32, 2, {4, 4}};
-
- // input reshaping to [20, 50]
- nnfw_tensorinfo input0_ti;
- {
- input0_ti.dtype = NNFW_TYPE_TENSOR_FLOAT32;
- input0_ti.rank = 2;
- input0_ti.dims[0] = 20;
- input0_ti.dims[1] = 50;
- }
-
- std::vector<float> input0(20 * 50);
- std::vector<float> actual_output(20 * 50);
- std::vector<float> expected_output(20 * 50);
-
- for (int i = 0; i < input0.size(); i++)
- {
- input0[i] = i * 1.1;
- expected_output[i] = -1 * input0[i];
- }
-
- NNFW_ENSURE_SUCCESS(nnfw_prepare(session));
-
- // input shape check
- {
- nnfw_tensorinfo ti = {};
- NNFW_ENSURE_SUCCESS(nnfw_input_tensorinfo(session, 0, &ti));
- ASSERT_TRUE(tensorInfoEqual(input0_ti_original, ti));
- }
-
- NNFW_ENSURE_SUCCESS(nnfw_set_input_tensorinfo(session, 0, &input0_ti));
-
- // input shape check
- {
- nnfw_tensorinfo ti = {};
- NNFW_ENSURE_SUCCESS(nnfw_input_tensorinfo(session, 0, &ti));
- ASSERT_TRUE(tensorInfoEqual(input0_ti, ti));
- }
-
- set_input_output(session, input0, actual_output);
-
- // Do inference
- NNFW_STATUS res = nnfw_run(session);
- NNFW_ENSURE_SUCCESS(res);
-
- // output value check
- for (int i = 0; i < expected_output.size(); ++i)
- ASSERT_EQ(expected_output[i], actual_output[i]);
-}
-
-using TestWhileDynamicModelLoaded = ValidationTestModelLoaded<NNPackages::WHILE_DYNAMIC>;
-
-// clang-format off
-const static std::vector<float> while_dynamic_input0{ 0.4325029254, 0.7332934141, 0.2969786823, 0.1540192217, 0.4608841240, 0.1523699313, 0.4334940016, 0.1022945493, 0.6928671598, 0.5891978741, 0.8283287883, 0.7041553259, 0.5243381262, 0.5623597503, 0.3395180404, 0.3212788701, 0.5248492956, 0.2551939189, 0.1338981092, 0.6406514645, 0.7089318633, 0.8164196610, 0.7689018846, 0.3551857173, 0.7668499351, 0.4942102134, 0.7345644236, 0.4689270556, 0.3495515287, 0.0768318549, 0.0868133679, 0.7823525667, 0.0791761801, 0.4397472143, 0.8150953054, 0.5074489713, 0.0895665437, 0.9451501966, 0.1064314246, 0.8803006411, 0.9903403521, 0.1259460151, 0.1889930069, 0.7466737032, 0.0553287826, 0.9712036252, 0.6352610588, 0.6301708817, 0.3079694211, 0.5367568731, 0.4070350230, 0.6815373302, 0.6948529482, 0.6158187985, 0.1485853940, 0.9162485600, 0.3622985184, 0.2672208250, 0.3396688998, 0.4135381579, 0.6450354457, 0.2386536747, 0.7072004080, 0.5289406180, 0.0643024296, 0.1969666779, 0.8667400479, 0.3396836221, 0.5878564715, 0.4551178813, 0.4318033755, 0.4376230836, 0.8211942315, 0.0230764486, 0.9005268812, 0.2147378176, 0.6036583781, 0.7161545157, 0.8246262074, 0.2989832759, 0.5491395593, 0.9779474735, 0.2006554008, 0.8227099776, 0.6018718481, 0.0132929254, 0.2212856710, 0.2032340616, 0.3059777319, 0.9094917178, 0.5409486890, 0.5595687032, 0.2436837852, 0.5649250150, 0.6730466485, 0.4421939552, 0.1432305574, 0.7053307891, 0.6284835935, 0.9216189384, 0.8686438799, 0.8385053873, 0.6248987913, 0.7697140574, 0.9808958173, 0.7571622133, 0.2297872156, 0.4201298952, 0.1305913031, 0.4572514296, 0.3072260618, 0.4668756723, 0.1919649392, 0.2050305754, 0.6062370539, 0.0006580966, 0.6217135191, 0.5123317838, 0.7305839658, 0.0610331446, 0.3614645600, 0.6455501914, 0.2919872701, 0.6446499228, 0.6293424964, 0.6947519779, 0.2680567801, 0.9756787419, 0.6422977448, 0.6911727786, 0.0343145914, 0.4764069021, 0.0876256451, 0.2926266789, 0.0487026349, 0.3558900952, 0.7788275480, 0.8566400409, 0.4791142642, 0.0595066175, 0.9609330297, 0.4075229764, 0.8758037090, 0.3485401869, 0.7945867181, 0.3457054794, 0.3327955306, 0.2870546579, 0.5697714090, 0.6144676208, 0.3251711428, 0.2342026234, 0.4153896868, 0.2149699926, 0.1064170301, 0.7240911722, 0.8196219206, 0.0208647959, 0.3081029952, 0.5742419958, 0.3027088642, 0.5005563498, 0.1707910597, 0.3358575106, 0.2290909439, 0.7788143754, 0.7611069679, 0.3525909781, 0.2308424413, 0.2585839927, 0.5973339677, 0.3728699684, 0.4975571036, 0.0781342834, 0.7119221091, 0.3926881850, 0.5501778126, 0.7364945412, 0.4965503812, 0.8785862923, 0.6024044752, 0.2638861239, 0.9093352556, 0.9069826007, 0.0359279662, 0.4043401778, 0.3457658887, 0.1013033912, 0.1810855120, 0.4946146905, 0.0194541160, 0.5453770161, 0.7965603471, 0.5493819714, 0.2422309667, 0.8376919031, 0.8350337148, 0.1898939908, 0.4576793313, 0.9535705447, 0.1353026628, 0.9474196434, 0.4256035388, 0.0255583692, 0.9593925476, 0.9245427847, 0.9780472517, 0.4356954992, 0.5673046708, 0.7346579432, 0.8614835143, 0.8782553673, 0.3395713866, 0.0013978065, 0.7640301585, 0.2504623234, 0.3626150787, 0.6888222694, 0.9404846430, 0.3519821763, 0.6855628490, 0.2415955663, 0.2107568830, 0.7718742490, 0.3419062793, 0.1280658394, 0.5126360059, 0.1722176671, 0.6543742418, 0.4206473231, 0.2138152719, 0.4514643848, 0.4293326437, 0.0042719250, 0.3195750117, 0.3874749541, 0.6262724400, 0.1620737463, 0.7417458892, 0.8521968126, 0.6405420303, 0.0713626966, 0.0474211276, 0.9068223834, 0.8541609645, 0.4279667437, 0.9738950133, 0.7167884707, 0.6812457442, 0.7938374281, 0.2077793330, 0.5163270831, 0.8487322927, 0.6320008039, 0.5116547942, 0.0056989277, 0.5253843665, 0.1517033428, 0.9921303988, 0.8305052519, 0.0771176443, 0.4621275961, 0.0299932379, 0.8129007220, 0.0946875364, 0.4544205368, 0.0143135618, 0.6373457313, 0.8202091455, 0.3447127640, 0.8560513258, 0.8079835773, 0.9697201252, 0.1521986276, 0.2269581258, 0.2245485932, 0.3396310210, 0.2649262249, 0.7799206972, 0.4020069242, 0.4444113672, 0.8123176098, 0.6460852027, 0.2041657269, 0.7889582515, 0.6526331902, 0.6626461744, 0.6049868464, 0.6901782155, 0.3364612758, 0.3053490818, 0.1905532777, 0.5362346172, 0.3618801832, 0.3485457003, 0.4509411156, 0.5986957550, 0.7858221531, 0.8822937012, 0.8280826807, 0.5261783004, 0.7312974334, 0.6962512732, 0.5243815780, 0.2492258698, 0.1734466404, 0.2547666430, 0.9950503111, 0.1781345457, 0.5630541444, 0.4552696049, 0.8874762058, 0.5965846777, 0.3575465977, 0.1213323772, 0.2790489793, 0.3157011569, 0.6218565702, 0.0304181967, 0.4112739265, 0.7361903787, 0.6753587723, 0.3667163849, 0.6275368929, 0.4185036719, 0.4791659117, 0.1246187463, 0.6651734114, 0.1778147966, 0.8796271682, 0.3000938296, 0.5996896029, 0.5020698309, 0.1601593345, 0.4467433393, 0.0287379269, 0.9011575580, 0.2722401917, 0.1642841995, 0.9468663335, 0.0238759480, 0.7811399102, 0.2070412934, 0.3746992052, 0.8473496437, 0.3498605192, 0.2693480551, 0.1523104310, 0.9660695791, 0.8762652278, 0.1654927284, 0.8743498921, 0.3143339157, 0.3896550536, 0.7256560922, 0.2408472896, 0.0930071324, 0.3269865215, 0.8070673347, 0.1218842566, 0.9943904281, 0.6901395917, 0.9491872787, 0.3617239892, 0.5459694862, 0.9408421516, 0.5354272127, 0.0377946161, 0.3319100142, 0.9823720455, 0.2373940945, 0.2439561784, 0.0767217800, 0.1102360934, 0.6404867172, 0.7430088520, 0.0165513344, 0.9841650128, 0.0532640740, 0.1635770351, 0.3721100390, 0.0598411299, 0.6548883319, 0.3812481761, 0.8741319180, 0.6431996226, 0.0550124273, 0.2009697258, 0.6922588348, 0.0673767105, 0.3385711610, 0.6945076585, 0.7870846987, 0.3323138356, 0.1601967812, 0.9595350623, 0.6049567461, 0.2068863660, 0.2562771440, 0.1041606516, 0.3444063365, 0.1464221030, 0.8932089210, 0.2040112168, 0.3407483399, 0.3251829743, 0.4777953327, 0.0534981787, 0.3613175154, 0.6707065105, 0.1188806742, 0.8228670359, 0.9907929897, 0.1556126177, 0.5561179519, 0.0124231419, 0.2054836601, 0.5855912566, 0.8455434442, 0.2268345803, 0.1841085702, 0.1096092239, 0.8316007257, 0.5046240687, 0.2195746899, 0.9222528338, 0.3633532226, 0.9383196831, 0.8803531528, 0.5124011636, 0.3909464478, 0.2731699646, 0.1102369502, 0.7489478588, 0.0600390583, 0.9290241599, 0.1041191891, 0.9347958565, 0.5584807396, 0.7331624031, 0.2267376930, 0.2868649662, 0.0016489516, 0.2301262319, 0.5107504129, 0.6500277519, 0.6766125560, 0.2019786686, 0.5890167952, 0.7182423472, 0.6890133023, 0.4442900419, 0.5760958791, 0.1364797056, 0.8246579766, 0.2527448535, 0.5444371700, 0.1561367512, 0.7551656961, 0.7171260715, 0.4264259040, 0.3883202970, 0.9166873693, 0.6557167768, 0.0264711548, 0.0761224255, 0.4693228602, 0.5476956964, 0.6261154413, 0.7666952610, 0.9579501152, 0.2581985295, 0.2322760671, 0.8342292905, 0.8143266439, 0.5771137476, 0.5815665126, 0.9772894382, 0.2359700650, 0.6501487494, 0.7841209769, 0.2793208659, 0.1745450795, 0.9626912475, 0.2373798192, 0.1235965416, 0.4632637799, 0.3763884604, 0.9971673489, 0.3533810079, 0.3203127384, 0.6102763414, 0.3859500289, 0.5929466486, 0.6658803821, 0.4130606949, 0.0352911949, 0.9713683128, 0.7546037436, 0.9780107737, 0.3970599473, 0.0187621433, 0.4941402078, 0.7670620680, 0.5360869765, 0.9634684920, 0.5996263027, 0.1895584762, 0.1214910895, 0.7381310463, 0.4301493466, 0.7403219938, 0.4817020297, 0.1843791455, 0.6473838091, 0.4138627350, 0.6825908422, 0.4481185675, 0.2030784935, 0.8468620777, 0.8059213758, 0.7525423169, 0.1854387224, 0.9046887755, 0.6654230952, 0.2029620409, 0.7164457440, 0.4172891080, 0.7797588110, 0.4135729969, 0.0026064927, 0.8375009894, 0.8355652690, 0.9187932014, 0.6724888086, 0.0276171323, 0.9106697440, 0.4562708735, 0.3417910039, 0.1569930464, 0.2029796541, 0.5049355626, 0.8143045306, 0.2432538420, 0.1068324223, 0.6258177757, 0.9749278426, 0.5378444791, 0.1657523215, 0.1930697113, 0.4833569825, 0.8000370264, 0.4315882921, 0.7571453452, 0.6069541574, 0.2073590159, 0.8702615499, 0.1951662153, 0.9303797483, 0.9241660833, 0.2795540988, 0.4241578877, 0.2383123934, 0.8627647758, 0.1700671613, 0.9635605216, 0.2514486313, 0.7766968012, 0.7126773596, 0.7009662986, 0.1317531914, 0.1318600327, 0.5509422421, 0.2159194350, 0.7851343751, 0.7231494188, 0.3523120880, 0.4999881089, 0.8202708960, 0.6340972185, 0.9181259274, 0.0057039275, 0.7197939754, 0.3580873907, 0.1026016176, 0.9657412767, 0.1973488480, 0.8099604845, 0.3302915096, 0.7635477781, 0.7097011805, 0.6271768212, 0.6583901644, 0.2334843278, 0.9448583126, 0.7434690595, 0.4068029821, 0.8815746307, 0.6311643124, 0.3891237080, 0.1507531852, 0.5215465426, 0.3248603344, 0.5837653279, 0.6689655185, 0.1362081915, 0.5130022764, 0.8519401550, 0.4397114217, 0.4129846096, 0.8706676960, 0.4183416367, 0.1135022715, 0.3501874208, 0.1142706573, 0.4111732543, 0.3972048163, 0.0740565360, 0.8445752263, 0.5659885406, 0.1107598469, 0.1261267066, 0.3106530905, 0.9623307586, 0.0014953646, 0.0421718284, 0.9182401299, 0.6180395484, 0.7947646379, 0.4402076006, 0.7980208993, 0.6131495237, 0.8885827065, 0.9406354427, 0.4568731785, 0.8838264346, 0.7086120248, 0.2050074339, 0.8598041534, 0.6360205412, 0.6444933414, 0.1086360887, 0.2146544755, 0.4044065177, 0.8566969037, 0.0974318087, 0.9650754929, 0.7885782719, 0.5817304850, 0.0668027699, 0.2600722611, 0.9546993971, 0.2609280050, 0.2063084394, 0.2960519791, 0.8144530654, 0.5386683941, 0.2757037580, 0.3237824142, 0.3469774723, 0.5878881812, 0.8034821153, 0.7495883107, 0.8035441637, 0.6059562564, 0.2713213861, 0.4108335674, 0.5539482832, 0.5046381950, 0.8435614705, 0.3766961098, 0.7583506107, 0.6175935268, 0.3487794399, 0.0058784639, 0.2900554240, 0.9057408571, 0.1079123169, 0.3200630546, 0.7326458693, 0.0237412248, 0.2757625282, 0.8461791873, 0.6101186872, 0.3705151379, 0.6318973899, 0.4013423026, 0.0222425349, 0.0391604938, 0.6966052055, 0.3186582327, 0.3277960122, 0.3301376998, 0.0874366611, 0.3782529831, 0.1412206143, 0.2574128807, 0.3423563242, 0.7656893730, 0.2097123116, 0.8109381199, 0.4845644534, 0.1744513661, 0.3877931535, 0.5369505286, 0.0147142150, 0.2457712293, 0.4901090264, 0.6373463869, 0.2244705260, 0.6722853184, 0.2888159454, 0.5694347620, 0.3042352200, 0.3482132256, 0.5619021654, 0.6760555506, 0.2648956776, 0.9160912037, 0.8973199129, 0.8901007175, 0.8260267973, 0.2438062280, 0.8338996172, 0.7751584649, 0.1436893344, 0.3578631580, 0.8111414909, 0.9454294443, 0.6478928924, 0.0714371502, 0.0711339787, 0.6473786235, 0.0266824700, 0.2442116290, 0.5528301001, 0.2558279037, 0.3684701622, 0.6729193330, 0.8132147193, 0.5830360651, 0.8655517101, 0.0593610443, 0.9748560190, 0.0221947283, 0.6729801893, 0.5001031756, 0.5116565824, 0.2824120522, 0.4552524984, 0.1693765223, 0.1908069402, 0.7663541436, 0.5339511037, 0.0649234429, 0.6125215292, 0.6771115661, 0.6019635797, 0.6840563416, 0.9653987288, 0.1369341463, 0.8428027630, 0.5227881670, 0.5990189910, 0.0936695337, 0.3645765185, 0.9354769588, 0.6745044589, 0.2816980183, 0.3783183694, 0.7331027389, 0.4139548242, 0.1671119779, 0.6703656316, 0.8604171872, 0.6643752456, 0.7547178268, 0.1386961490, 0.4443438351, 0.3267543018, 0.3348949254, 0.9952459931, 0.4534417391, 0.2089741081 };
-const static std::vector<float> while_dynamic_output0{ 0.0388205424, 0.0426156297, 0.0980401114, 0.0568757951, 0.1230962500, 0.0412184112, 0.0595490113, 0.4391007423, 0.0377574340, 0.0629260018 };
-// clang-format on
-
-TEST_F(TestWhileDynamicModelLoaded, run_verify)
-{
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(_session, "cpu"));
- NNFW_ENSURE_SUCCESS(nnfw_prepare(_session));
-
- std::vector<float> actual_output0(10);
-
- nnfw_tensorinfo ti = {NNFW_TYPE_TENSOR_FLOAT32, 3, {1, 28, 28}};
- NNFW_ENSURE_SUCCESS(nnfw_set_input_tensorinfo(_session, 0, &ti));
-
- set_input_output(_session, while_dynamic_input0, actual_output0);
-
- NNFW_ENSURE_SUCCESS(nnfw_run(_session));
-
- nnfw_tensorinfo ti_output0_expected = {NNFW_TYPE_TENSOR_FLOAT32, 2, {1, 10}};
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(_session, 0, &ti));
- ASSERT_TRUE(tensorInfoEqual(ti, ti_output0_expected));
-
- // output value check
- for (int i = 0; i < actual_output0.size(); ++i)
- ASSERT_FLOAT_EQ(while_dynamic_output0[i], actual_output0[i]);
-}
-
-TEST_F(TestWhileDynamicModelLoaded, neg_run_verify)
-{
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(_session, "cpu"));
- NNFW_ENSURE_SUCCESS(nnfw_prepare(_session));
-
- nnfw_tensorinfo ti = {NNFW_TYPE_TENSOR_FLOAT32, 3, {1, 28, 28}};
- NNFW_ENSURE_SUCCESS(nnfw_set_input_tensorinfo(_session, 0, &ti));
-
- // Insufficient size of output (10 or more is sufficient)
- std::vector<float> actual_output0(9);
-
- set_input_output(_session, while_dynamic_input0, actual_output0);
-
- ASSERT_EQ(nnfw_run(_session), NNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE);
-}
-
-using TestIfDynamicModelLoaded = ValidationTestModelLoaded<NNPackages::IF_DYNAMIC>;
-
-// clang-format off
-const static std::vector<float> if_dynamic_input0{ 0.7106545568, 0.2156167328, 0.0837147385, 0.0381200500, 0.8007305861, 0.2976274490, 0.8563324213, 0.7781477571, 0.5745304823, 0.8303883672, 0.0862579569, 0.0544887781, 0.1988027841, 0.2230974138, 0.4716774523, 0.4606758952, 0.4920695722, 0.1058474109, 0.0391142406, 0.9550740719, 0.9775217772, 0.1644495875, 0.6734005809, 0.2771040201, 0.4015675485, 0.9389892220, 0.5739571452, 0.6168602109, 0.4262073934, 0.1955287308, 0.6361171603, 0.3251913190, 0.9311535358, 0.9403554797, 0.2734249830, 0.8866292834, 0.5992837548, 0.2142961770, 0.7889495492, 0.0741494149, 0.1030917764, 0.4724597037, 0.3861218989, 0.8098146915, 0.2832616270, 0.6557519436, 0.5689851642, 0.8294774294, 0.4495503902, 0.5395354629, 0.7472639680, 0.4290334582, 0.6575341225, 0.3844197690, 0.5194811821, 0.9411858320, 0.8186575174, 0.6588338614, 0.5179415941, 0.7074140310, 0.1678132862, 0.7229011655, 0.3164389431, 0.6544682384, 0.7210181952, 0.0454275832, 0.6507202387, 0.4012205899, 0.2719061375, 0.2579342127, 0.1064170823, 0.5994709730, 0.1010676920, 0.3968397975, 0.5670611858, 0.1786351353, 0.9127767086, 0.9268618822, 0.6603804827, 0.3673154712, 0.3415949941, 0.5930755138, 0.3685272932, 0.6884198189, 0.1833280921, 0.3941298127, 0.0632725284, 0.1516269594, 0.2316887528, 0.8105147481, 0.1674028039, 0.2784884572, 0.5205677748, 0.4399658442, 0.6527903080, 0.6785870790, 0.2533956766, 0.0617546029, 0.5094803572, 0.5204600096, 0.0249194298, 0.0450648703, 0.1241398007, 0.3705165386, 0.9986394048, 0.6402000785, 0.4894598126, 0.8702902794, 0.4500190616, 0.8115220070, 0.8781826496, 0.6121248603, 0.9077111483, 0.4646541476, 0.7442384362, 0.5584337115, 0.0265889056, 0.9247944951, 0.5661407709, 0.9730864167, 0.6722183824, 0.9564477801, 0.6998952627, 0.6105464697, 0.8297851086, 0.7167860270, 0.6002981067, 0.4256598651, 0.1964918524, 0.9581518769, 0.3121621907, 0.8813912272, 0.3803862929, 0.8825226426, 0.9783715010, 0.1397246420, 0.6996101737, 0.1947445422, 0.9981691837, 0.9528205395, 0.1440794915, 0.2994889319, 0.9605104923, 0.7394120097, 0.8036665916, 0.1226263046, 0.5607838035, 0.5100311637, 0.9977583289, 0.1812620014, 0.8162402511, 0.6829946637, 0.8054547906, 0.5318715572, 0.2573204339, 0.6401459575, 0.9395645857, 0.0523465686, 0.1189657971, 0.4010948837, 0.5229173303, 0.3700955212, 0.8600971103, 0.2058345824, 0.0952973440, 0.6578513980, 0.8096982241, 0.3292799890, 0.3189097345, 0.2228140533, 0.7665079832, 0.3701375425, 0.7601019740, 0.8501300216, 0.5380855203, 0.7509619594, 0.8447382450, 0.6025870442, 0.6957519054, 0.6805172563, 0.5877657533, 0.3472520709, 0.0291769207, 0.0723123997, 0.4284786880, 0.5264689922, 0.4927068353, 0.7379829884, 0.9378200173, 0.8644418716, 0.8671935797, 0.9434295297, 0.5507473350, 0.0760083497, 0.1079615131, 0.1603826135, 0.2987570167, 0.4970068038, 0.0533443913, 0.7932291627, 0.4054899216, 0.8708239794, 0.8852948546, 0.7709504366, 0.2500700951, 0.7328734398, 0.1770015359, 0.4787373245, 0.6746702790, 0.6232759953, 0.8252257109, 0.5074343681, 0.4582579136, 0.7136889100, 0.1850759387, 0.0999758169, 0.9016878009, 0.0968299136, 0.9786298275, 0.7106815577, 0.5932894945, 0.5901473165, 0.8644450903, 0.8777941465, 0.3545308709, 0.5543619394, 0.4764245450, 0.4866352081, 0.7842248678, 0.8535351157, 0.8261910677, 0.4928103089, 0.4883008599, 0.9132300615, 0.0520589016, 0.0571883246, 0.8107213974, 0.2263001502, 0.4195134640, 0.1585850269, 0.6892622709, 0.9932649732, 0.9146085382, 0.3438154757, 0.3597939610, 0.8383805156, 0.1434784085, 0.1592836231, 0.3735914230, 0.5118701458, 0.6597173810, 0.5932899714, 0.7643446326, 0.7639417052, 0.7257087231, 0.8367394209, 0.7241969705, 0.2863937616, 0.7383541465, 0.3918549418, 0.8693540096, 0.8002281189, 0.0121407788, 0.3702836633, 0.3193098009, 0.2857846618, 0.3450623155, 0.8419249654, 0.4484305680, 0.0768098459, 0.1011011526, 0.9832069874, 0.2806532979, 0.6486470103, 0.0038275064, 0.5200383663, 0.5825559497, 0.8526763320, 0.2604954541, 0.4765493274, 0.8257845044, 0.9679267406, 0.3583108485, 0.5755933523, 0.6114814878, 0.5805739164, 0.1076851040, 0.0532303862, 0.3102329671, 0.2268214077, 0.3422079682, 0.3890814781, 0.2123251557, 0.6259000301, 0.9530308843, 0.2377676368, 0.4969599247, 0.3911451399, 0.6869695187, 0.4768487513, 0.0319234431, 0.5153809190, 0.7592291832, 0.5699093938, 0.6517769098, 0.1294958293, 0.5191193819, 0.9886645675, 0.2082915604, 0.9330775738, 0.1966033280, 0.7179551721, 0.4047450423, 0.3280299902, 0.7132403255, 0.7453812361, 0.1643252373, 0.0279585645, 0.0323586352, 0.0771650672, 0.8751529455, 0.3228718042, 0.0091584828, 0.2462333292, 0.2639203966, 0.1246995181, 0.7825807929, 0.0825880542, 0.5019466281, 0.5546332598, 0.2470002472, 0.3974646032, 0.3941309452, 0.2988025546, 0.5270965099, 0.0565799475, 0.7965186834, 0.8401004672, 0.8962592483, 0.2836867571, 0.9854408503, 0.1736569554, 0.3543607295, 0.1489263922, 0.0296417754, 0.8644942045, 0.5768237114, 0.5055403709, 0.7033663988, 0.7610059381, 0.7680964470, 0.9276048541, 0.4661210179, 0.1926902831, 0.8331482410, 0.3478438258, 0.4423305690, 0.1226840168, 0.2631755769, 0.7300418615, 0.8501742482, 0.7732837200, 0.1645421237, 0.9328539968, 0.3299001455, 0.1737864316, 0.6760513186, 0.6878529191, 0.8000500202, 0.7643007040, 0.8427000046, 0.7743517756, 0.4847290516, 0.5107879639, 0.1321444362, 0.2521093190, 0.6971111894, 0.9226302505, 0.7618960738, 0.0798677281, 0.9345219731, 0.3526974618, 0.5779649615, 0.6659775376, 0.0080328183, 0.6179481745, 0.3388322592, 0.8871348500, 0.3849443495, 0.5805974007, 0.4485530853, 0.0118454825, 0.1535516083, 0.9892683029, 0.6305456758, 0.8417525887, 0.9201779366, 0.5443179011, 0.3694557250, 0.9480580688, 0.0420885272, 0.3705308735, 0.1857404709, 0.2711791396, 0.3184533417, 0.2894020677, 0.8524381518, 0.1369639933, 0.5524237156, 0.2515565455, 0.2611325383, 0.7106022239, 0.7720850706, 0.5917789340, 0.1294544786, 0.1406515092, 0.4081685841, 0.7773256898, 0.0337970816, 0.2720888555, 0.6040735841, 0.4713420272, 0.2154571265, 0.7050493360, 0.5699684024, 0.8653516769, 0.2943878472, 0.0710595697, 0.7601916790, 0.8260607719, 0.5490139127, 0.2270360142, 0.6353984475, 0.0237506367, 0.1613635123, 0.2657604814, 0.9112974405, 0.3940451145, 0.9857107997, 0.6584201455, 0.2996906042, 0.6385321617, 0.3025711179, 0.5442391634, 0.5316760540, 0.9278558493, 0.2960957289, 0.2758596539, 0.8092618585, 0.7210826278, 0.5532572269, 0.0433825813, 0.4293606579, 0.9231137037, 0.7861453891, 0.0529759154, 0.2881730795, 0.4177611172, 0.0751738325, 0.2110737860, 0.0087767169, 0.9394732714, 0.7669738531, 0.1285874546, 0.0892729312, 0.7701640129, 0.3619799912, 0.1591310948, 0.5716432333, 0.3634774089, 0.5689123273, 0.1703432053, 0.7500917912, 0.8368289471, 0.6899937391, 0.8733949065, 0.3469920754, 0.9645365477, 0.9452517629, 0.0622390397, 0.0313139819, 0.9253467917, 0.5542111993, 0.4027656317, 0.5191525817, 0.3981988430, 0.7461462021, 0.6761778593, 0.2998072505, 0.8195981979, 0.6851982474, 0.0545753241, 0.1639913172, 0.8172791600, 0.7425212264, 0.1970316321, 0.1586989313, 0.3941454589, 0.8775137067, 0.3532845676, 0.1445332468, 0.4015854299, 0.7155395746, 0.4261780679, 0.7957311273, 0.8265135884, 0.5879834294, 0.7252638340, 0.3942884803, 0.7504889965, 0.5733796358, 0.7747340798, 0.9431585670, 0.5627400875, 0.3371616900, 0.6190663576, 0.5733695626, 0.2214016914, 0.8767938614, 0.2509712279, 0.6909803748, 0.3777657151, 0.6170743704, 0.7373610735, 0.0204360615, 0.7325904369, 0.4920690358, 0.5081653595, 0.9917234182, 0.2093250901, 0.8361138105, 0.7211740017, 0.2606147230, 0.3064637780, 0.1124278903, 0.6320124269, 0.2425052077, 0.4785803258, 0.4747911394, 0.8021139503, 0.3956191838, 0.7217889428, 0.7445480227, 0.1360257119, 0.3709513843, 0.5552678704, 0.2192365974, 0.9431814551, 0.8592399359, 0.7907270789, 0.5545215607, 0.6895139813, 0.1169689223, 0.2043674886, 0.0381150991, 0.7708708644, 0.4759636819, 0.9230924845, 0.6857032776, 0.4432366490, 0.3041133285, 0.7970084548, 0.5629503727, 0.2329168320, 0.2320910394, 0.8098289967, 0.8152811527, 0.9269255996, 0.2628753185, 0.7178934216, 0.1607068628, 0.6057552695, 0.5256694555, 0.5559988022, 0.8001552820, 0.5592993498, 0.5585735440, 0.7596833110, 0.4926379025, 0.8108907342, 0.5142205954, 0.8292154074, 0.9844856262, 0.9281103611, 0.8271671534, 0.8411998153, 0.4101325572, 0.9839829803, 0.1782312542, 0.5126013756, 0.4867194891, 0.9041156173, 0.8752650619, 0.9434064627, 0.5353408456, 0.3405859768, 0.9340458512, 0.1240679324, 0.5371315479, 0.3755141199, 0.2990591526, 0.0670647249, 0.0626592115, 0.7673836946, 0.2539713681, 0.4617587030, 0.9303754568, 0.4884444177, 0.9808034897, 0.7934950590, 0.9362392426, 0.8001930714, 0.8370914459, 0.4767935276, 0.8847136497, 0.8713309765, 0.8301703334, 0.9254899621, 0.5875709057, 0.4544037282, 0.2598260045, 0.7427998781, 0.7183818817, 0.9003841877, 0.0916625410, 0.2609814405, 0.6743535399, 0.7733583450, 0.7338136435, 0.7596724033, 0.7973198891, 0.0015392932, 0.2874146104, 0.1189730167, 0.4800435603, 0.7962353230, 0.4249678552, 0.7483268380, 0.0146148857, 0.6297842860, 0.3471757770, 0.9144366980, 0.8106345534, 0.1789025515, 0.7346886992, 0.1539165080, 0.4280290008, 0.2338476181, 0.3317435384, 0.9998268485, 0.3580373228, 0.9422348738, 0.1251947135, 0.5737128258, 0.6803853512, 0.0485891216, 0.8118965626, 0.7890921235, 0.7665926218, 0.8405004144, 0.3489693701, 0.1429360062, 0.1063490957, 0.5086215734, 0.1312662065, 0.0978318676, 0.4471830130, 0.0830681920, 0.0757851526, 0.1809245348, 0.9280508757, 0.4107315242, 0.5944178104, 0.5625417829, 0.2328256220, 0.9285324812, 0.9903659821, 0.9403946996, 0.5126894712, 0.0232842807, 0.3405880928, 0.6531285644, 0.8213183880, 0.7210904360, 0.4180826247, 0.7917050719, 0.7738851309, 0.1693093032, 0.4396123290, 0.7139748335, 0.8910710216, 0.5668603778, 0.4374921620, 0.8098046780, 0.4076835811, 0.1027061120, 0.5390046835, 0.0044658147, 0.8642644286, 0.8590582609, 0.2715446949, 0.8128718734, 0.7381446362, 0.3621498942, 0.5211849809, 0.6139976382, 0.8567240834, 0.1329502016, 0.2441152930, 0.4219030440, 0.1751736850, 0.6326612234, 0.3929811120, 0.0947103724, 0.1078760102, 0.8769059777, 0.1599343121, 0.6111860275, 0.0368208028, 0.0899466202, 0.9127882719, 0.1146656275, 0.4647151828, 0.3303563893, 0.5797663927, 0.8400436044, 0.2845958769, 0.2181742340, 0.9651557207, 0.1241061762, 0.0102593508, 0.6999664903, 0.8487475514, 0.6001151800, 0.9682601690, 0.6127328873, 0.1502806544, 0.2512893379, 0.3930048048, 0.3448313475, 0.5263126493, 0.7319667935, 0.9264212251, 0.4489789009, 0.0418849625, 0.5219999552, 0.3397078812, 0.4435234964, 0.4758536220, 0.1290920675, 0.1649249196, 0.1736114621, 0.5685442686, 0.3253444433, 0.0540574715, 0.2022368759, 0.0260062832, 0.9889448285, 0.2064949423, 0.3756456375, 0.8462600112, 0.8166462779, 0.1788506061, 0.6607533097, 0.1638182998, 0.7888727188, 0.3304887116, 0.3085075021, 0.6626392603, 0.2860932350, 0.1577534527, 0.0126363616, 0.1958409399, 0.2475458980, 0.1514713019, 0.5241229534, 0.9845717549, 0.8002693653, 0.3091083765, 0.3348104060, 0.1341333240, 0.3546191454, 0.3800157905, 0.0364337005 };
-const static std::vector<float> if_dynamic_output0{ 0.0444660522, 0.0271649156, 0.0191113371, 0.0014375688, 0.0690929219, 0.0001767588, 0.0030322229, 0.0118752792, 0.0419745520, 0.7816683054 };
-// clang-format on
-
-TEST_F(TestIfDynamicModelLoaded, run_verify)
-{
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(_session, "cpu"));
- NNFW_ENSURE_SUCCESS(nnfw_prepare(_session));
-
- nnfw_tensorinfo ti_output0_expected = {NNFW_TYPE_TENSOR_FLOAT32, 2, {1, 10}};
-
- // Output tensor sizes are inferenced after `nnfw_prepare`
- {
- nnfw_tensorinfo ti;
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(_session, 0, &ti));
- ASSERT_TRUE(tensorInfoEqual(ti, ti_output0_expected));
- }
-
- std::vector<float> actual_output0(10);
- set_input_output(_session, if_dynamic_input0, actual_output0);
-
- NNFW_ENSURE_SUCCESS(nnfw_run(_session));
-
- // Check output tensor sizes again
- {
- nnfw_tensorinfo ti;
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(_session, 0, &ti));
- ASSERT_TRUE(tensorInfoEqual(ti, ti_output0_expected));
- }
-
- // Output value check
- for (int i = 0; i < actual_output0.size(); ++i)
- ASSERT_NEAR(if_dynamic_output0[i], actual_output0[i], 0.00001);
-}
diff --git a/tests/nnfw_api/src/ModelTestInputReshaping.cc b/tests/nnfw_api/src/ModelTestInputReshaping.cc
deleted file mode 100644
index f5ce3e062..000000000
--- a/tests/nnfw_api/src/ModelTestInputReshaping.cc
+++ /dev/null
@@ -1,97 +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.
- */
-
-#include <gtest/gtest.h>
-#include <nnfw_internal.h>
-
-#include "fixtures.h"
-#include "common.h"
-#include "CircleGen.h"
-
-/**
- * @brief Testing the following model:
- * #1 = placeholder (shape = [2, 2], dtype=float)
- * #2 = placeholder (shape = [2], dtype=float)
- * #3 = add(#1, #2)
- */
-auto build_model_add_input_reshaping()
-{
- // Model is not important
- CircleGen cgen;
- auto f32 = circle::TensorType::TensorType_FLOAT32;
- int in1 = cgen.addTensor({{2, 2}, f32}); // consider this [None, None]
- int in2 = cgen.addTensor({{2}, f32});
- int out = cgen.addTensor({{}, f32}); // scalar, meaning output shape is unspecified
- cgen.addOperatorAdd({{in1, in2}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in1, in2}, {out});
- auto cbuf = cgen.finish();
- return cbuf;
-}
-
-TEST(TestDynamicTensor, input_reshaping)
-{
- nnfw_session *session = nullptr;
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&session));
- const auto model_buf = build_model_add_input_reshaping();
- NNFW_ENSURE_SUCCESS(nnfw_load_circle_from_buffer(session, model_buf.buffer(), model_buf.size()));
-
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(session, "cpu"));
-
- // input and output values
- const std::vector<float> input1 = {0, 1, 2, 3, 4, 5, 6, 7}; // of changed shape [4, 2]
- const std::vector<float> input2 = {-10, -10};
- const std::vector<float> expected = {-10, -9, -8, -7, -6, -5, -4, -3}; // of shape [4, 2]
-
- /*
- testing sequence and what's been done:
- 1. nnfw_set_input_tensorinfo : set input shape to different shape (static inference)
- 2. nnfw_prepare
- 3. nnfw_set_input
- 4. nnfw_run
- */
-
- // input reshaping from [2, 2] to [4, 2]
- nnfw_tensorinfo ti = {NNFW_TYPE_TENSOR_FLOAT32, 2, {4, 2}};
- NNFW_ENSURE_SUCCESS(nnfw_set_input_tensorinfo(session, 0, &ti));
-
- NNFW_ENSURE_SUCCESS(nnfw_prepare(session));
-
- nnfw_tensorinfo ti_input = {}; // Static inference result will be stored
- NNFW_ENSURE_SUCCESS(nnfw_input_tensorinfo(session, 0, &ti_input));
- ASSERT_TRUE(tensorInfoEqual(ti, ti_input));
-
- nnfw_tensorinfo ti_output = {}; // Static inference result will be stored
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(session, 0, &ti_output));
- ASSERT_TRUE(tensorInfoEqual(ti, ti_output)); // input/output shapes are same with for this model
-
- NNFW_ENSURE_SUCCESS(nnfw_set_input(session, 0, NNFW_TYPE_TENSOR_FLOAT32, input1.data(),
- sizeof(float) * input1.size()));
- NNFW_ENSURE_SUCCESS(nnfw_set_input(session, 1, NNFW_TYPE_TENSOR_FLOAT32, input2.data(),
- sizeof(float) * input2.size()));
-
- uint64_t output_num_elements = tensorInfoNumElements(ti_output);
- ASSERT_EQ(output_num_elements, expected.size());
- std::vector<float> actual_output(output_num_elements);
- NNFW_ENSURE_SUCCESS(nnfw_set_output(session, 0, NNFW_TYPE_TENSOR_FLOAT32, actual_output.data(),
- sizeof(float) * actual_output.size()));
-
- // Do inference
- NNFW_ENSURE_SUCCESS(nnfw_run(session));
-
- // compare
- for (int i = 0; i < expected.size(); ++i)
- ASSERT_EQ(expected[i], actual_output[i]);
-}
diff --git a/tests/nnfw_api/src/NNPackages.cc b/tests/nnfw_api/src/NNPackages.cc
deleted file mode 100644
index b0febb7a1..000000000
--- a/tests/nnfw_api/src/NNPackages.cc
+++ /dev/null
@@ -1,98 +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.
- */
-
-#include "NNPackages.h"
-
-#include <unistd.h>
-#include <libgen.h>
-#include <string.h>
-#include <dirent.h>
-#include <assert.h>
-#include <stdexcept>
-
-// NOTE Must match `enum TestPackages`
-const char *TEST_PACKAGE_NAMES[] = {
- // for validation test
- "add", "add_no_manifest", "add_invalid_manifest",
-
- // for dynamic tensor test
- "while_dynamic", "if_dynamic",
-};
-
-NNPackages &NNPackages::get()
-{
- static NNPackages instance;
- return instance;
-}
-
-void NNPackages::init(const char *argv0)
-{
- char raw_dir[1024];
- char cwd[1024];
- strncpy(raw_dir, argv0, sizeof(raw_dir) - 1);
- dirname(raw_dir);
- if (raw_dir[0] == '/')
- {
- // If it is an absolute path, just use it
- _base_path = raw_dir;
- }
- else
- {
- // If it is a relative path, prepend CWD
- getcwd(cwd, sizeof(cwd));
- _base_path = cwd;
- _base_path += "/";
- _base_path += raw_dir;
- }
-}
-
-void NNPackages::checkAll()
-{
- assert(!_base_path.empty());
-
- for (int i = 0; i < NNPackages::COUNT; i++)
- {
- std::string package_name = TEST_PACKAGE_NAMES[i];
- std::string path = getModelAbsolutePath(i);
-
- DIR *dir = opendir(path.c_str());
- if (!dir)
- {
- std::string msg =
- "missing nnpackage: " + package_name + ", path: " + path +
- "\nPlease run \'[install_dir]/test/onert-test prepare-model --nnpackage\' to "
- "download nnpackage";
- throw std::runtime_error{msg};
- }
- closedir(dir);
- }
-}
-
-std::string NNPackages::getModelAbsolutePath(int package_no)
-{
- if (package_no < 0 || package_no >= NNPackages::COUNT)
- {
- throw std::runtime_error{"Invalid package_no: " + std::to_string(package_no)};
- }
-
- const char *package_dir = TEST_PACKAGE_NAMES[package_no];
- return getModelAbsolutePath(package_dir);
-}
-
-std::string NNPackages::getModelAbsolutePath(const char *package_name)
-{
- return _base_path + "/nnfw_api_gtest_models/" + package_name + "/" + package_name;
-}
diff --git a/tests/nnfw_api/src/NNPackages.h b/tests/nnfw_api/src/NNPackages.h
deleted file mode 100644
index a51b7701d..000000000
--- a/tests/nnfw_api/src/NNPackages.h
+++ /dev/null
@@ -1,95 +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 __NNFW_API_TEST_MODEL_PATH_H__
-#define __NNFW_API_TEST_MODEL_PATH_H__
-
-#include <string>
-
-/**
- * @brief A helper class to find NN Packages for testing
- * To add a nnpackage for your test, please do the followings:
- * 0. Prerequisite: the actual file must be uploaded on the server
- * Add `config.sh` file to `tests/scripts/models/nnfw_api_gtest`
- * 1. Append an enum value to @c NNPackages::TestPackages
- * 2. Append a string literal to @c TEST_PACKAGE_NAMES in the source file
- */
-class NNPackages
-{
-public:
- /**
- * @brief Serial numbers for test packages. The numbers are mapped with package names.
- * This is useful for creating GTest Fixtures with variable template to perform
- * different nn packages with no code duplication.
- */
- enum TestPackages
- {
- // for validation test
- ADD,
- ADD_NO_MANIFEST, //< Contains "Add" model but no manifest file
- ADD_INVALID_MANIFEST, //< Contains "Add" model but the manifest file is broken JSON
-
- // for dynamic tensor test
- WHILE_DYNAMIC,
- IF_DYNAMIC,
-
- COUNT
- };
-
- /*
- * @brief Singleton object getter
- *
- * @return NNPackages& The singleton object
- */
- static NNPackages &get();
-
- /**
- * @brief Get the Absolute of the model to find
- *
- * @param package_no Model's serial number
- * @return std::string The absolute path of model directory
- */
- std::string getModelAbsolutePath(int package_no);
-
- /**
- * @brief Get the absolute of the model to find
- *
- * @param package_name Package name
- * @return std::string The absolute path of model directory
- */
- std::string getModelAbsolutePath(const char *package_name);
-
- /**
- * @brief Save the current executable's directory based on argv[0] and CWD
- *
- * @param argv0 0th command line argument of the current process
- */
- void init(const char *argv0);
-
- /**
- * @brief Check all the nnpackages are installed
- * Must be run after @c init .
- */
- void checkAll();
-
-private:
- NNPackages() = default;
-
-private:
- std::string _base_path;
-};
-
-#endif // __NNFW_API_TEST_MODEL_PATH_H__
diff --git a/tests/nnfw_api/src/RegressionTests.cc b/tests/nnfw_api/src/RegressionTests.cc
deleted file mode 100644
index 10d6e5d6e..000000000
--- a/tests/nnfw_api/src/RegressionTests.cc
+++ /dev/null
@@ -1,178 +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.
- */
-
-#include "fixtures.h"
-#include "NNPackages.h"
-
-#include <nnfw_internal.h>
-
-#include "CircleGen.h"
-
-TEST_F(RegressionTest, github_1535)
-{
- auto package_path = NNPackages::get().getModelAbsolutePath(NNPackages::ADD);
-
- nnfw_session *session1 = nullptr;
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&session1));
- NNFW_ENSURE_SUCCESS(nnfw_load_model_from_file(session1, package_path.c_str()));
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(session1, "cpu;acl_cl;acl_neon"));
- NNFW_ENSURE_SUCCESS(nnfw_prepare(session1));
-
- nnfw_session *session2 = nullptr;
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&session2));
- NNFW_ENSURE_SUCCESS(nnfw_load_model_from_file(session2, package_path.c_str()));
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(session2, "cpu"));
- NNFW_ENSURE_SUCCESS(nnfw_prepare(session2));
-
- NNFW_ENSURE_SUCCESS(nnfw_close_session(session1));
- NNFW_ENSURE_SUCCESS(nnfw_close_session(session2));
-
- SUCCEED();
-}
-
-TEST_F(RegressionTest, neg_github_3826)
-{
- // Model is not important
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAveragePool2D({{in}, {out}}, circle::Padding_SAME, 2, 2, 2, 2,
- circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
- auto cbuf = cgen.finish();
-
- nnfw_session *session = nullptr;
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&session));
- NNFW_ENSURE_SUCCESS(nnfw_load_circle_from_buffer(session, cbuf.buffer(), cbuf.size()));
- // To test when there is no backends loaded for the session
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(session, "unavailable_backend"));
- ASSERT_EQ(nnfw_prepare(session), NNFW_STATUS_ERROR);
- NNFW_ENSURE_SUCCESS(nnfw_close_session(session));
-}
-
-TEST_F(RegressionTest, github_11748)
-{
- // At the 1st call, input tensor is static. From the 2nd call, input tensor becomes dynamic.
- // the following model and calling sequence were what nnstreamer people used for their test case.
- CircleGen cgen;
- int lhs = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
-
- std::vector<float> rhs_data{2};
- uint32_t rhs_buf = cgen.addBuffer(rhs_data);
- int rhs = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, rhs_buf});
-
- int out = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{lhs, rhs}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({lhs}, {out});
- auto cbuf = cgen.finish();
-
- nnfw_session *session = nullptr;
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&session));
- NNFW_ENSURE_SUCCESS(nnfw_load_circle_from_buffer(session, cbuf.buffer(), cbuf.size()));
- // To test when there is no backends loaded for the session
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(session, "cpu"));
- NNFW_ENSURE_SUCCESS(nnfw_prepare(session));
-
- uint32_t input_num = -1;
- NNFW_ENSURE_SUCCESS(nnfw_input_size(session, &input_num));
-
- nnfw_tensorinfo t_input;
- NNFW_ENSURE_SUCCESS(nnfw_input_tensorinfo(session, 0, &t_input));
-
- uint32_t output_num = -1;
- NNFW_ENSURE_SUCCESS(nnfw_output_size(session, &output_num));
-
- nnfw_tensorinfo t_output;
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(session, 0, &t_output));
-
- // when new_dim == 1, input tensor is static. From 2, input tensor becomes dynamic.
- for (int32_t new_dim = 1; new_dim <= 4; new_dim++)
- {
- nnfw_tensorinfo t_new_input;
- t_new_input.dtype = t_input.dtype;
- t_new_input.rank = 1;
- t_new_input.dims[0] = new_dim;
- NNFW_ENSURE_SUCCESS(nnfw_set_input_tensorinfo(session, 0, &t_new_input));
-
- NNFW_ENSURE_SUCCESS(nnfw_input_size(session, &input_num));
- NNFW_ENSURE_SUCCESS(nnfw_input_tensorinfo(session, 0, &t_input));
-
- ASSERT_EQ(input_num, 1);
- ASSERT_EQ(t_input.rank, t_new_input.rank);
- ASSERT_EQ(t_input.dims[0], new_dim);
-
- uint8_t input_buf[new_dim * sizeof(float)];
- NNFW_ENSURE_SUCCESS(
- nnfw_set_input(session, 0, t_input.dtype, &input_buf, new_dim * sizeof(float)));
-
- uint8_t output_buf[new_dim * sizeof(float)];
- NNFW_ENSURE_SUCCESS(
- nnfw_set_output(session, 0, t_output.dtype, &output_buf, new_dim * sizeof(float)));
-
- NNFW_ENSURE_SUCCESS(nnfw_run(session));
-
- NNFW_ENSURE_SUCCESS(nnfw_output_size(session, &output_num));
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(session, 0, &t_output));
-
- ASSERT_EQ(output_num, 1);
- ASSERT_EQ(t_output.rank, t_new_input.rank);
- ASSERT_EQ(t_output.dims[0], new_dim);
-
- // seems weird calling but anyway nnstreamer people case calls this again.
- // Anyways, runtime should work
- NNFW_ENSURE_SUCCESS(
- nnfw_set_input(session, 0, t_input.dtype, &input_buf, new_dim * sizeof(float)));
- NNFW_ENSURE_SUCCESS(
- nnfw_set_output(session, 0, t_output.dtype, &output_buf, new_dim * sizeof(float)));
- NNFW_ENSURE_SUCCESS(nnfw_run(session));
- }
-
- NNFW_ENSURE_SUCCESS(nnfw_close_session(session));
-}
-
-TEST_F(RegressionTest, github_4585)
-{
- // A single tensor which is an input and an output at the same time
- CircleGen cgen;
- int t = cgen.addTensor({{1, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.setInputsAndOutputs({t}, {t});
- auto cbuf = cgen.finish();
-
- nnfw_session *session = nullptr;
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&session));
- NNFW_ENSURE_SUCCESS(nnfw_load_circle_from_buffer(session, cbuf.buffer(), cbuf.size()));
- // To test when there is no backends loaded for the session
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(session, "cpu"));
- NNFW_ENSURE_SUCCESS(nnfw_prepare(session));
-
- // Change input tensorinfo (Make dynamic shape inference happen)
- nnfw_tensorinfo ti_new = {NNFW_TYPE_TENSOR_FLOAT32, 2, {1, 2}};
- NNFW_ENSURE_SUCCESS(nnfw_set_input_tensorinfo(session, 0, &ti_new));
-
- std::vector<float> in_buf{1, 1};
- std::vector<float> out_buf{-1, -1};
-
- NNFW_ENSURE_SUCCESS(
- nnfw_set_input(session, 0, ti_new.dtype, in_buf.data(), in_buf.size() * sizeof(float)));
- NNFW_ENSURE_SUCCESS(
- nnfw_set_output(session, 0, ti_new.dtype, out_buf.data(), out_buf.size() * sizeof(float)));
-
- NNFW_ENSURE_SUCCESS(nnfw_run(session));
-
- ASSERT_EQ(in_buf, out_buf);
-
- NNFW_ENSURE_SUCCESS(nnfw_close_session(session));
-}
diff --git a/tests/nnfw_api/src/ValidationTestAddModelLoaded.cc b/tests/nnfw_api/src/ValidationTestAddModelLoaded.cc
deleted file mode 100644
index 1d3d4fc93..000000000
--- a/tests/nnfw_api/src/ValidationTestAddModelLoaded.cc
+++ /dev/null
@@ -1,124 +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.
- */
-
-#include "fixtures.h"
-#include "NNPackages.h"
-
-using ValidationTestAddModelLoaded = ValidationTestModelLoaded<NNPackages::ADD>;
-
-TEST_F(ValidationTestAddModelLoaded, prepare_001)
-{
- NNFW_ENSURE_SUCCESS(nnfw_prepare(_session));
-
- SUCCEED();
-}
-
-TEST_F(ValidationTestAddModelLoaded, set_available_backends_001)
-{
- NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(_session, "cpu"));
-
- SUCCEED();
-}
-
-TEST_F(ValidationTestAddModelLoaded, get_input_size)
-{
- uint32_t size = 0;
- NNFW_ENSURE_SUCCESS(nnfw_input_size(_session, &size));
- ASSERT_EQ(size, 1);
-}
-
-TEST_F(ValidationTestAddModelLoaded, get_output_size)
-{
- uint32_t size = 0;
- NNFW_ENSURE_SUCCESS(nnfw_output_size(_session, &size));
- ASSERT_EQ(size, 1);
-}
-
-TEST_F(ValidationTestAddModelLoaded, output_tensorinfo)
-{
- nnfw_tensorinfo tensor_info;
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(_session, 0, &tensor_info));
- ASSERT_EQ(tensor_info.rank, 1);
- ASSERT_EQ(tensor_info.dims[0], 1);
-}
-
-TEST_F(ValidationTestAddModelLoaded, input_output_tensorindex)
-{
- uint32_t in_ind = 100;
- NNFW_ENSURE_SUCCESS(nnfw_input_tensorindex(_session, "X_input", &in_ind));
- ASSERT_EQ(in_ind, 0);
-
- uint32_t out_ind = 100;
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorindex(_session, "ADD_TOP", &out_ind));
- ASSERT_EQ(out_ind, 0);
-}
-
-TEST_F(ValidationTestAddModelLoaded, neg_run)
-{
- // nnfw_prepare is not called
- ASSERT_EQ(nnfw_run(_session), NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestAddModelLoaded, neg_set_input)
-{
- // nnfw_prepare is not called
- ASSERT_EQ(nnfw_set_input(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 0),
- NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestAddModelLoaded, neg_set_output)
-{
- // nnfw_prepare is not called
- ASSERT_EQ(nnfw_set_output(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 0),
- NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestAddModelLoaded, neg_get_input_size)
-{
- ASSERT_EQ(nnfw_input_size(_session, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestAddModelLoaded, neg_get_output_size)
-{
- ASSERT_EQ(nnfw_output_size(_session, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestAddModelLoaded, neg_load_model)
-{
- // load model twice
- ASSERT_EQ(nnfw_load_model_from_file(
- _session, NNPackages::get().getModelAbsolutePath(NNPackages::ADD).c_str()),
- NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestAddModelLoaded, neg_output_tensorinfo)
-{
- // tensor_info is null
- ASSERT_EQ(nnfw_output_tensorinfo(_session, 0, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestAddModelLoaded, neg_input_output_tensorindex)
-{
- uint32_t in_ind = 100;
- ASSERT_EQ(nnfw_input_tensorindex(_session, "ADD_TOP", &in_ind), NNFW_STATUS_ERROR);
- ASSERT_EQ(in_ind, 100);
- ASSERT_EQ(nnfw_input_tensorindex(_session, "y_var", &in_ind), NNFW_STATUS_ERROR);
- ASSERT_EQ(in_ind, 100);
-
- uint32_t out_ind = 100;
- ASSERT_EQ(nnfw_output_tensorindex(_session, "X_input", &out_ind), NNFW_STATUS_ERROR);
- ASSERT_EQ(out_ind, 100);
-}
diff --git a/tests/nnfw_api/src/ValidationTestAddSessionPrepared.cc b/tests/nnfw_api/src/ValidationTestAddSessionPrepared.cc
deleted file mode 100644
index e2ae655be..000000000
--- a/tests/nnfw_api/src/ValidationTestAddSessionPrepared.cc
+++ /dev/null
@@ -1,194 +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.
- */
-
-#include "fixtures.h"
-#include "NNPackages.h"
-
-using ValidationTestAddSessionPrepared = ValidationTestSessionPrepared<NNPackages::ADD>;
-
-TEST_F(ValidationTestAddSessionPrepared, run)
-{
- SetInOutBuffers();
- _input[0] = 3.0;
- NNFW_ENSURE_SUCCESS(nnfw_run(_session));
- ASSERT_FLOAT_EQ(_output[0], 5.0);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, run_twice)
-{
- SetInOutBuffers();
- _input[0] = 4.0;
- NNFW_ENSURE_SUCCESS(nnfw_run(_session));
- ASSERT_FLOAT_EQ(_output[0], 6.0);
-
- _input[0] = 5.0f;
- NNFW_ENSURE_SUCCESS(nnfw_run(_session));
- ASSERT_FLOAT_EQ(_output[0], 7.0);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, run_many_times_dynamic_input)
-{
- for (int v = 1; v <= 5; v++) // 5 times with different shapes
- {
- nnfw_tensorinfo ti_input = {NNFW_TYPE_TENSOR_FLOAT32, 4, {1, 1, 1, v}};
- SetInOutBuffersDynamic(&ti_input);
-
- for (int i = 0; i < v; i++)
- _input[i] = i * 10.0;
-
- NNFW_ENSURE_SUCCESS(nnfw_run(_session));
-
- // Check if the shape inference is correct
- nnfw_tensorinfo ti_output;
- ASSERT_EQ(nnfw_output_tensorinfo(_session, 0, &ti_output), NNFW_STATUS_NO_ERROR);
- EXPECT_EQ(num_elems(&ti_input), num_elems(&ti_output));
-
- for (int i = 0; i < v; i++)
- ASSERT_FLOAT_EQ(_output[i], i * 10.0 + 2.0) << "i : " << i;
- }
-}
-
-TEST_F(ValidationTestAddSessionPrepared, run_async)
-{
- SetInOutBuffers();
- _input[0] = 3.0;
- NNFW_ENSURE_SUCCESS(nnfw_run_async(_session));
- NNFW_ENSURE_SUCCESS(nnfw_await(_session));
- ASSERT_FLOAT_EQ(_output[0], 5.0);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, set_input_001)
-{
- char input[32];
- ASSERT_EQ(nnfw_set_input(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, input, sizeof(input)),
- NNFW_STATUS_NO_ERROR);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, get_input_size)
-{
- uint32_t size = 0;
- NNFW_ENSURE_SUCCESS(nnfw_input_size(_session, &size));
- ASSERT_EQ(size, 1);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, get_output_size)
-{
- uint32_t size = 0;
- NNFW_ENSURE_SUCCESS(nnfw_output_size(_session, &size));
- ASSERT_EQ(size, 1);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, output_tensorinfo)
-{
- nnfw_tensorinfo tensor_info;
- NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(_session, 0, &tensor_info));
- ASSERT_EQ(tensor_info.rank, 1);
- ASSERT_EQ(tensor_info.dims[0], 1);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_await_without_async_run)
-{
- SetInOutBuffers();
- ASSERT_EQ(nnfw_await(_session), NNFW_STATUS_ERROR);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_await_after_sync_run)
-{
- SetInOutBuffers();
- NNFW_ENSURE_SUCCESS(nnfw_run(_session));
- ASSERT_EQ(nnfw_await(_session), NNFW_STATUS_ERROR);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_await_twice)
-{
- SetInOutBuffers();
- NNFW_ENSURE_SUCCESS(nnfw_run_async(_session));
- NNFW_ENSURE_SUCCESS(nnfw_await(_session));
- ASSERT_EQ(nnfw_await(_session), NNFW_STATUS_ERROR);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_run_during_async_run)
-{
- SetInOutBuffers();
- NNFW_ENSURE_SUCCESS(nnfw_run_async(_session));
- EXPECT_EQ(nnfw_run(_session), NNFW_STATUS_INVALID_STATE);
- NNFW_ENSURE_SUCCESS(nnfw_await(_session));
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_set_input_001)
-{
- ASSERT_EQ(nnfw_set_input(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 1), NNFW_STATUS_ERROR);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_set_input_002)
-{
- char input[1]; // buffer size is too small
- ASSERT_EQ(nnfw_set_input(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, input, sizeof(input)),
- NNFW_STATUS_ERROR);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, set_output_001)
-{
- char buffer[32];
- ASSERT_EQ(nnfw_set_input(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, buffer, sizeof(buffer)),
- NNFW_STATUS_NO_ERROR);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_set_output_001)
-{
- ASSERT_EQ(nnfw_set_output(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 1), NNFW_STATUS_ERROR);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_set_output_002)
-{
- char input[1]; // buffer size is too small
- ASSERT_EQ(nnfw_set_output(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, input, sizeof(input)),
- NNFW_STATUS_ERROR);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_get_input_size)
-{
- ASSERT_EQ(nnfw_input_size(_session, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_get_output_size)
-{
- ASSERT_EQ(nnfw_output_size(_session, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_load_model)
-{
- // Load model twice
- ASSERT_EQ(nnfw_load_model_from_file(
- _session, NNPackages::get().getModelAbsolutePath(NNPackages::ADD).c_str()),
- NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_prepare)
-{
- // Call Prepare twice
- ASSERT_EQ(nnfw_prepare(_session), NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestAddSessionPrepared, neg_run_without_set_output)
-{
- uint8_t input[4];
- NNFW_ENSURE_SUCCESS(nnfw_set_input(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, input, sizeof(input)));
- // `nnfw_set_output()` is not called
- ASSERT_EQ(nnfw_run(_session), NNFW_STATUS_ERROR);
-}
-
-// TODO Validation check when "nnfw_run" is called without input & output tensor setting
diff --git a/tests/nnfw_api/src/ValidationTestFourAddModelsSetInput.cc b/tests/nnfw_api/src/ValidationTestFourAddModelsSetInput.cc
deleted file mode 100644
index e09402b01..000000000
--- a/tests/nnfw_api/src/ValidationTestFourAddModelsSetInput.cc
+++ /dev/null
@@ -1,50 +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.
- */
-
-#include "NNPackages.h"
-#include "fixtures.h"
-
-using ValidationTestFourAddModelsSetInput = ValidationTestFourModelsSetInput<NNPackages::ADD>;
-
-TEST_F(ValidationTestFourAddModelsSetInput, run_001)
-{
- NNFW_ENSURE_SUCCESS(nnfw_run(_objects[0].session));
- NNFW_ENSURE_SUCCESS(nnfw_run(_objects[1].session));
-
- SUCCEED();
-}
-
-TEST_F(ValidationTestFourAddModelsSetInput, run_002)
-{
- int rep = 3;
- while (rep--)
- {
- for (auto obj : _objects)
- NNFW_ENSURE_SUCCESS(nnfw_run(obj.session));
- }
-
- SUCCEED();
-}
-
-TEST_F(ValidationTestFourAddModelsSetInput, run_async)
-{
- for (auto obj : _objects)
- NNFW_ENSURE_SUCCESS(nnfw_run_async(obj.session));
- for (auto obj : _objects)
- NNFW_ENSURE_SUCCESS(nnfw_await(obj.session));
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/ValidationTestSessionCreated.cc b/tests/nnfw_api/src/ValidationTestSessionCreated.cc
deleted file mode 100644
index 4ef14f745..000000000
--- a/tests/nnfw_api/src/ValidationTestSessionCreated.cc
+++ /dev/null
@@ -1,120 +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.
- */
-
-#include "NNPackages.h"
-#include "fixtures.h"
-
-TEST_F(ValidationTestSessionCreated, load_session_001)
-{
- // Existing model must
- ASSERT_EQ(nnfw_load_model_from_file(
- _session, NNPackages::get().getModelAbsolutePath(NNPackages::ADD).c_str()),
- NNFW_STATUS_NO_ERROR);
-}
-
-TEST_F(ValidationTestSessionCreated, close_and_create_again)
-{
- NNFW_ENSURE_SUCCESS(nnfw_close_session(_session));
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&_session));
-
- SUCCEED();
-}
-
-TEST_F(ValidationTestSessionCreated, neg_load_session_1)
-{
- ASSERT_EQ(nnfw_load_model_from_file(
- _session, NNPackages::get().getModelAbsolutePath("nonexisting_directory").c_str()),
- NNFW_STATUS_ERROR);
-}
-
-TEST_F(ValidationTestSessionCreated, neg_load_session_2)
-{
- ASSERT_EQ(nnfw_load_model_from_file(_session, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestSessionCreated, neg_load_session_3)
-{
- // Too long path
- const std::string long_path(1024, 'x');
- ASSERT_EQ(nnfw_load_model_from_file(
- _session, NNPackages::get().getModelAbsolutePath(long_path.c_str()).c_str()),
- NNFW_STATUS_ERROR);
-}
-
-TEST_F(ValidationTestSessionCreated, neg_load_invalid_package_1)
-{
- ASSERT_EQ(
- nnfw_load_model_from_file(
- _session, NNPackages::get().getModelAbsolutePath(NNPackages::ADD_NO_MANIFEST).c_str()),
- NNFW_STATUS_ERROR);
- ASSERT_EQ(nnfw_prepare(_session), NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestSessionCreated, neg_load_invalid_package_2)
-{
- ASSERT_EQ(nnfw_load_model_from_file(
- _session,
- NNPackages::get().getModelAbsolutePath(NNPackages::ADD_INVALID_MANIFEST).c_str()),
- NNFW_STATUS_ERROR);
- ASSERT_EQ(nnfw_prepare(_session), NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestSessionCreated, neg_prepare_001)
-{
- // nnfw_load_model_from_file was not called
- ASSERT_EQ(nnfw_prepare(_session), NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestSessionCreated, neg_run_001)
-{
- // nnfw_load_model_from_file and nnfw_prepare was not called
- ASSERT_EQ(nnfw_run(_session), NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestSessionCreated, neg_set_input_001)
-{
- ASSERT_EQ(nnfw_set_input(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 0),
- NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestSessionCreated, neg_set_output_001)
-{
- ASSERT_EQ(nnfw_set_output(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 0),
- NNFW_STATUS_INVALID_STATE);
-}
-
-TEST_F(ValidationTestSessionCreated, neg_get_input_size)
-{
- uint32_t size = 10000;
- ASSERT_EQ(nnfw_input_size(_session, &size), NNFW_STATUS_INVALID_STATE);
- ASSERT_EQ(size, 10000); // Remain unchanged
-}
-
-TEST_F(ValidationTestSessionCreated, neg_get_output_size)
-{
- uint32_t size = 10000;
- ASSERT_EQ(nnfw_output_size(_session, &size), NNFW_STATUS_INVALID_STATE);
- ASSERT_EQ(size, 10000); // Remain unchanged
-}
-
-TEST_F(ValidationTestSessionCreated, neg_output_tensorinfo)
-{
- nnfw_tensorinfo tensor_info;
- // model is not loaded
- ASSERT_EQ(nnfw_output_tensorinfo(_session, 0, &tensor_info), NNFW_STATUS_INVALID_STATE);
- // model is not loaded and tensor_info is null
- ASSERT_EQ(nnfw_output_tensorinfo(_session, 0, nullptr), NNFW_STATUS_INVALID_STATE);
-}
diff --git a/tests/nnfw_api/src/ValidationTestSingleSession.cc b/tests/nnfw_api/src/ValidationTestSingleSession.cc
deleted file mode 100644
index c74649203..000000000
--- a/tests/nnfw_api/src/ValidationTestSingleSession.cc
+++ /dev/null
@@ -1,111 +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.
- */
-
-#include "NNPackages.h"
-#include "fixtures.h"
-
-TEST_F(ValidationTestSingleSession, create_001)
-{
- NNFW_ENSURE_SUCCESS(nnfw_create_session(&_session));
- NNFW_ENSURE_SUCCESS(nnfw_close_session(_session));
-
- SUCCEED();
-}
-
-TEST_F(ValidationTestSingleSession, query_info_u32)
-{
- uint32_t val = 0;
- NNFW_ENSURE_SUCCESS(nnfw_query_info_u32(nullptr, NNFW_INFO_ID_VERSION, &val));
-
- SUCCEED();
-}
-
-TEST_F(ValidationTestSingleSession, neg_create_001)
-{
- ASSERT_EQ(nnfw_create_session(nullptr), NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestSingleSession, neg_run_001)
-{
- ASSERT_EQ(nnfw_run(nullptr), NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestSingleSession, neg_set_input_001)
-{
- // Invalid session
- ASSERT_EQ(nnfw_set_input(nullptr, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 0),
- NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestSingleSession, neg_set_input_002)
-{
- char input[32];
- ASSERT_EQ(nnfw_set_input(nullptr, 0, NNFW_TYPE_TENSOR_FLOAT32, input, sizeof(input)),
- NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestSingleSession, neg_set_output_001)
-{
- // Invalid session
- ASSERT_EQ(nnfw_set_output(nullptr, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 0),
- NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestSingleSession, neg_set_output_002)
-{
- char buffer[32];
- ASSERT_EQ(nnfw_set_output(nullptr, 0, NNFW_TYPE_TENSOR_FLOAT32, buffer, sizeof(buffer)),
- NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestSingleSession, neg_get_input_size)
-{
- uint32_t size = 10000;
- ASSERT_EQ(nnfw_input_size(nullptr, &size), NNFW_STATUS_UNEXPECTED_NULL);
- ASSERT_EQ(size, 10000);
-}
-
-TEST_F(ValidationTestSingleSession, neg_get_output_size)
-{
- uint32_t size = 10000;
- ASSERT_EQ(nnfw_output_size(nullptr, &size), NNFW_STATUS_UNEXPECTED_NULL);
- ASSERT_EQ(size, 10000);
-}
-
-TEST_F(ValidationTestSingleSession, neg_load_model)
-{
- // Invalid state
- ASSERT_EQ(nnfw_load_model_from_file(
- nullptr, NNPackages::get().getModelAbsolutePath(NNPackages::ADD).c_str()),
- NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestSingleSession, neg_prepare_001)
-{
- ASSERT_EQ(nnfw_prepare(nullptr), NNFW_STATUS_UNEXPECTED_NULL);
-}
-
-TEST_F(ValidationTestSingleSession, neg_query_info_u32)
-{
- ASSERT_EQ(nnfw_query_info_u32(nullptr, NNFW_INFO_ID_VERSION, nullptr), NNFW_STATUS_ERROR);
-}
-
-TEST_F(ValidationTestSingleSession, neg_output_tensorinfo)
-{
- nnfw_tensorinfo tensor_info;
- ASSERT_EQ(nnfw_output_tensorinfo(nullptr, 0, &tensor_info), NNFW_STATUS_UNEXPECTED_NULL);
- ASSERT_EQ(nnfw_output_tensorinfo(nullptr, 0, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
-}
diff --git a/tests/nnfw_api/src/common.cc b/tests/nnfw_api/src/common.cc
deleted file mode 100644
index 3c3bc68d0..000000000
--- a/tests/nnfw_api/src/common.cc
+++ /dev/null
@@ -1,40 +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.
- */
-
-#include "common.h"
-
-bool tensorInfoEqual(const nnfw_tensorinfo &info1, const nnfw_tensorinfo &info2)
-{
- if (info1.dtype != info2.dtype)
- return false;
- if (info1.rank != info2.rank)
- return false;
- for (int i = 0; i < info1.rank; i++)
- if (info1.dims[i] != info2.dims[i])
- return false;
- return true;
-}
-
-uint64_t tensorInfoNumElements(const nnfw_tensorinfo &ti)
-{
- uint64_t n = 1;
- for (uint32_t i = 0; i < ti.rank; ++i)
- {
- n *= ti.dims[i];
- }
- return n;
-}
diff --git a/tests/nnfw_api/src/common.h b/tests/nnfw_api/src/common.h
deleted file mode 100644
index aec49792c..000000000
--- a/tests/nnfw_api/src/common.h
+++ /dev/null
@@ -1,26 +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 __NNFW_API_TEST_COMMON_H__
-#define __NNFW_API_TEST_COMMON_H__
-
-#include <gtest/gtest.h>
-#include <nnfw.h>
-
-bool tensorInfoEqual(const nnfw_tensorinfo &info1, const nnfw_tensorinfo &info2);
-uint64_t tensorInfoNumElements(const nnfw_tensorinfo &info);
-
-#endif // __NNFW_API_TEST_COMMON_H__
diff --git a/tests/nnfw_api/src/fixtures.h b/tests/nnfw_api/src/fixtures.h
deleted file mode 100644
index 0cb67b5e2..000000000
--- a/tests/nnfw_api/src/fixtures.h
+++ /dev/null
@@ -1,208 +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 __NNFW_API_TEST_FIXTURES_H__
-#define __NNFW_API_TEST_FIXTURES_H__
-
-#include <array>
-#include <gtest/gtest.h>
-#include <nnfw_experimental.h>
-
-#include "NNPackages.h"
-
-#define NNFW_ENSURE_SUCCESS(EXPR) ASSERT_EQ((EXPR), NNFW_STATUS_NO_ERROR)
-
-inline uint64_t num_elems(const nnfw_tensorinfo *ti)
-{
- uint64_t n = 1;
- for (uint32_t i = 0; i < ti->rank; ++i)
- {
- n *= ti->dims[i];
- }
- return n;
-}
-
-struct SessionObject
-{
- nnfw_session *session = nullptr;
- std::vector<std::vector<float>> inputs;
- std::vector<std::vector<float>> outputs;
-};
-
-class ValidationTest : public ::testing::Test
-{
-protected:
- void SetUp() override {}
-};
-
-class RegressionTest : public ::testing::Test
-{
-protected:
- void SetUp() override {}
-};
-
-class ValidationTestSingleSession : public ValidationTest
-{
-protected:
- nnfw_session *_session = nullptr;
-};
-
-class ValidationTestSessionCreated : public ValidationTestSingleSession
-{
-protected:
- void SetUp() override
- {
- ValidationTestSingleSession::SetUp();
- ASSERT_EQ(nnfw_create_session(&_session), NNFW_STATUS_NO_ERROR);
- }
-
- void TearDown() override
- {
- ASSERT_EQ(nnfw_close_session(_session), NNFW_STATUS_NO_ERROR);
- ValidationTestSingleSession::TearDown();
- }
-};
-
-template <int PackageNo> class ValidationTestModelLoaded : public ValidationTestSessionCreated
-{
-protected:
- void SetUp() override
- {
- ValidationTestSessionCreated::SetUp();
- ASSERT_EQ(nnfw_load_model_from_file(_session,
- NNPackages::get().getModelAbsolutePath(PackageNo).c_str()),
- NNFW_STATUS_NO_ERROR);
- ASSERT_NE(_session, nullptr);
- }
-
- void TearDown() override { ValidationTestSessionCreated::TearDown(); }
-};
-
-template <int PackageNo>
-class ValidationTestSessionPrepared : public ValidationTestModelLoaded<PackageNo>
-{
-protected:
- using ValidationTestSingleSession::_session;
-
- void SetUp() override
- {
- ValidationTestModelLoaded<PackageNo>::SetUp();
- nnfw_prepare(_session);
- }
-
- void TearDown() override { ValidationTestModelLoaded<PackageNo>::TearDown(); }
-
- void SetInOutBuffers()
- {
- nnfw_tensorinfo ti_input;
- ASSERT_EQ(nnfw_input_tensorinfo(_session, 0, &ti_input), NNFW_STATUS_NO_ERROR);
- uint64_t input_elements = num_elems(&ti_input);
- EXPECT_EQ(input_elements, 1);
- _input.resize(input_elements);
- ASSERT_EQ(
- nnfw_set_input(_session, 0, ti_input.dtype, _input.data(), sizeof(float) * input_elements),
- NNFW_STATUS_NO_ERROR);
-
- nnfw_tensorinfo ti_output;
- ASSERT_EQ(nnfw_output_tensorinfo(_session, 0, &ti_output), NNFW_STATUS_NO_ERROR);
- uint64_t output_elements = num_elems(&ti_output);
- EXPECT_EQ(output_elements, 1);
- _output.resize(output_elements);
- ASSERT_EQ(nnfw_set_output(_session, 0, ti_output.dtype, _output.data(),
- sizeof(float) * output_elements),
- NNFW_STATUS_NO_ERROR);
- }
-
- void SetInOutBuffersDynamic(const nnfw_tensorinfo *ti_input)
- {
- NNFW_ENSURE_SUCCESS(nnfw_set_input_tensorinfo(_session, 0, ti_input));
- uint64_t input_elements = num_elems(ti_input);
- _input.resize(input_elements);
- ASSERT_EQ(
- nnfw_set_input(_session, 0, ti_input->dtype, _input.data(), sizeof(float) * input_elements),
- NNFW_STATUS_NO_ERROR);
-
- _output.resize(40000); // Give sufficient size for the output
- ASSERT_EQ(nnfw_set_output(_session, 0, ti_input->dtype, _output.data(),
- sizeof(float) * _output.size()),
- NNFW_STATUS_NO_ERROR);
- }
-
-protected:
- std::vector<float> _input;
- std::vector<float> _output;
-};
-
-template <int PackageNo> class ValidationTestFourModelsSetInput : public ValidationTest
-{
-protected:
- static const uint32_t NUM_SESSIONS = 4;
-
- void SetUp() override
- {
- ValidationTest::SetUp();
-
- auto model_path = NNPackages::get().getModelAbsolutePath(NNPackages::ADD);
- for (auto &obj : _objects)
- {
- ASSERT_EQ(nnfw_create_session(&obj.session), NNFW_STATUS_NO_ERROR);
- ASSERT_EQ(nnfw_load_model_from_file(obj.session, model_path.c_str()), NNFW_STATUS_NO_ERROR);
- ASSERT_EQ(nnfw_prepare(obj.session), NNFW_STATUS_NO_ERROR);
-
- uint32_t num_inputs;
- ASSERT_EQ(nnfw_input_size(obj.session, &num_inputs), NNFW_STATUS_NO_ERROR);
- obj.inputs.resize(num_inputs);
- for (uint32_t ind = 0; ind < obj.inputs.size(); ind++)
- {
- nnfw_tensorinfo ti;
- ASSERT_EQ(nnfw_input_tensorinfo(obj.session, ind, &ti), NNFW_STATUS_NO_ERROR);
- uint64_t input_elements = num_elems(&ti);
- obj.inputs[ind].resize(input_elements);
- ASSERT_EQ(nnfw_set_input(obj.session, ind, ti.dtype, obj.inputs[ind].data(),
- sizeof(float) * input_elements),
- NNFW_STATUS_NO_ERROR);
- }
-
- uint32_t num_outputs;
- ASSERT_EQ(nnfw_output_size(obj.session, &num_outputs), NNFW_STATUS_NO_ERROR);
- obj.outputs.resize(num_outputs);
- for (uint32_t ind = 0; ind < obj.outputs.size(); ind++)
- {
- nnfw_tensorinfo ti;
- ASSERT_EQ(nnfw_output_tensorinfo(obj.session, ind, &ti), NNFW_STATUS_NO_ERROR);
- uint64_t output_elements = num_elems(&ti);
- obj.outputs[ind].resize(output_elements);
- ASSERT_EQ(nnfw_set_output(obj.session, ind, ti.dtype, obj.outputs[ind].data(),
- sizeof(float) * output_elements),
- NNFW_STATUS_NO_ERROR);
- }
- }
- }
-
- void TearDown() override
- {
- for (auto &obj : _objects)
- {
- ASSERT_EQ(nnfw_close_session(obj.session), NNFW_STATUS_NO_ERROR);
- }
- ValidationTest::TearDown();
- }
-
-protected:
- std::array<SessionObject, NUM_SESSIONS> _objects;
-};
-
-#endif // __NNFW_API_TEST_FIXTURES_H__
diff --git a/tests/nnfw_api/src/main.cc b/tests/nnfw_api/src/main.cc
deleted file mode 100644
index 741c0fb47..000000000
--- a/tests/nnfw_api/src/main.cc
+++ /dev/null
@@ -1,39 +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.
- */
-
-#include <iostream>
-#include <stdexcept>
-#include <string>
-#include <gtest/gtest.h>
-#include "NNPackages.h"
-
-int main(int argc, char **argv)
-{
- NNPackages::get().init(argv[0]);
- ::testing::InitGoogleTest(&argc, argv);
-
- try
- {
- NNPackages::get().checkAll();
- }
- catch (std::runtime_error &e)
- {
- std::cerr << e.what() << std::endl;
- return -1;
- }
-
- return RUN_ALL_TESTS();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Add.cc b/tests/nnfw_api/src/one_op_tests/Add.cc
deleted file mode 100644
index 1fff0ed30..000000000
--- a/tests/nnfw_api/src/one_op_tests/Add.cc
+++ /dev/null
@@ -1,166 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_Add_VarToConst)
-{
- CircleGen cgen;
- std::vector<float> rhs_data{5, 4, 7, 4};
- uint32_t rhs_buf = cgen.addBuffer(rhs_data);
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32, rhs_buf});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{lhs, rhs}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({lhs}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 3, 2, 4}}, {{6, 7, 9, 8}}));
- _context->addTestCase(uniformTCD<float>({{0, 1, 2, 3}}, {{5, 5, 9, 7}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Add_VarToVar)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{lhs, rhs}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({lhs, rhs}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 3, 2, 4}, {5, 4, 7, 4}}, {{6, 7, 9, 8}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Add_VarToVarSame)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{in, in}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 3, 2, 4}}, {{2, 6, 4, 8}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Add_InvalidShape)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 3, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 3, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{lhs, rhs}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({lhs, rhs}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Add_InvalidShapeConst)
-{
- CircleGen cgen;
- std::vector<float> rhs_data{5, 4, 0, 7, 4, 0};
- uint32_t rhs_buf = cgen.addBuffer(rhs_data);
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32, rhs_buf});
- int out = cgen.addTensor({{1, 2, 3, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{lhs, rhs}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({lhs, rhs}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Add_OneOperand)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 3, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{in}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Add_ThreeOperands)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 3, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{in, in, in}, {out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Add_NoOutput)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 3, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{in}, {}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Add_InvalidActivation)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{lhs, rhs}, {out}},
- static_cast<circle::ActivationFunctionType>(128) /* Invalid value*/);
- cgen.setInputsAndOutputs({lhs, rhs}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 3, 2, 4}, {5, 4, 7, 4}}, {{6, 7, 9, 8}}));
- _context->setBackends({"cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/ArgMax.cc b/tests/nnfw_api/src/one_op_tests/ArgMax.cc
deleted file mode 100644
index 2876d8d70..000000000
--- a/tests/nnfw_api/src/one_op_tests/ArgMax.cc
+++ /dev/null
@@ -1,122 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_ArgMax_AxisToConst)
-{
- CircleGen cgen;
- const auto output_type = circle::TensorType::TensorType_INT32;
- std::vector<int32_t> axis_data{1};
- uint32_t axis_buf = cgen.addBuffer(axis_data);
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, axis_buf});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 1}, output_type});
- cgen.addOperatorArgMax({{in, axis}, {out}}, output_type);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<float>{1, 4, 2, 3});
- tcd.addOutput(std::vector<int32_t>{1, 0});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_ArgMax_Int64_AxisToConst)
-{
- CircleGen cgen;
- const auto output_type = circle::TensorType::TensorType_INT64;
- std::vector<int32_t> axis_data{1};
- uint32_t axis_buf = cgen.addBuffer(axis_data);
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, axis_buf});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 1}, output_type});
- cgen.addOperatorArgMax({{in, axis}, {out}}, output_type);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<float>{1, 4, 2, 3});
- tcd.addOutput(std::vector<int64_t>{1, 0});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_ArgMax_AxisToVar)
-{
- CircleGen cgen;
- const auto output_type = circle::TensorType::TensorType_INT32;
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 1}, output_type});
- cgen.addOperatorArgMax({{in, axis}, {out}}, output_type);
- cgen.setInputsAndOutputs({in, axis}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<float>{1, 4, 2, 3});
- tcd.addInput(std::vector<int32_t>{-3});
- tcd.addOutput(std::vector<int32_t>{1, 0});
- _context->addTestCase(tcd);
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_ArgMax_InvalidAxis0)
-{
- CircleGen cgen;
- const auto output_type = circle::TensorType::TensorType_INT32;
- std::vector<int32_t> axis_data{4};
- uint32_t axis_buf = cgen.addBuffer(axis_data);
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, axis_buf});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 1}, output_type});
- cgen.addOperatorArgMax({{in, axis}, {out}}, output_type);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_ArgMax_InvalidAxis1)
-{
- CircleGen cgen;
- const auto output_type = circle::TensorType::TensorType_INT32;
- std::vector<int32_t> axis_data{-3};
- uint32_t axis_buf = cgen.addBuffer(axis_data);
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, axis_buf});
- int in = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{2}, output_type});
- cgen.addOperatorArgMax({{in, axis}, {out}}, output_type);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/AveragePool2D.cc b/tests/nnfw_api/src/one_op_tests/AveragePool2D.cc
deleted file mode 100644
index 8ba82083f..000000000
--- a/tests/nnfw_api/src/one_op_tests/AveragePool2D.cc
+++ /dev/null
@@ -1,124 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_AvgPool2D)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAveragePool2D({{in}, {out}}, circle::Padding_SAME, 2, 2, 2, 2,
- circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 3, 2, 4}}, {{2.5}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_AvgPool2D)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAveragePool2D({{in}, {out}}, circle::Padding_SAME, 2, 2, 2, 2,
- circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_AvgPool2D_InvalidPaddingType)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAveragePool2D({{in}, {out}}, static_cast<circle::Padding>(99), 2, 2, 2, 2,
- circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_AvgPool2D_InvalidFilterSize_1)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAveragePool2D({{in}, {out}}, circle::Padding_SAME, 2, 2, -1, 2,
- circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_AvgPool2D_InvalidFilterSize_2)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAveragePool2D({{in}, {out}}, circle::Padding_SAME, 2, 2, 2, 0,
- circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_AvgPool2D_InvalidStrides_1)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAveragePool2D({{in}, {out}}, circle::Padding_SAME, 0, 2, 2, 2,
- circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_AvgPool2D_InvalidStrides_2)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAveragePool2D({{in}, {out}}, circle::Padding_SAME, 1, -100, 2, 2,
- circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Cast.cc b/tests/nnfw_api/src/one_op_tests/Cast.cc
deleted file mode 100644
index 71d98ee59..000000000
--- a/tests/nnfw_api/src/one_op_tests/Cast.cc
+++ /dev/null
@@ -1,159 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_Cast_Int32ToFloat32)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorCast({{in}, {out}}, circle::TensorType::TensorType_INT32,
- circle::TensorType::TensorType_FLOAT32);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<int32_t>{1, 2, 3, 4});
- tcd.addOutput(std::vector<float>{1, 2, 3, 4});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Cast_Float32ToInt32)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
- cgen.addOperatorCast({{in}, {out}}, circle::TensorType::TensorType_FLOAT32,
- circle::TensorType::TensorType_INT32);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<float>{1, 2, 3, 4});
- tcd.addOutput(std::vector<int32_t>{1, 2, 3, 4});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Cast_BoolToFloat32)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_BOOL});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorCast({{in}, {out}}, circle::TensorType::TensorType_BOOL,
- circle::TensorType::TensorType_FLOAT32);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<bool>{true, false, true, true});
- tcd.addOutput(std::vector<float>{1, 0, 1, 1});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Cast_AfterEqual)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int equal_out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_BOOL});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorEqual({{lhs, rhs}, {equal_out}});
- cgen.addOperatorCast({{equal_out}, {out}}, circle::TensorType::TensorType_BOOL,
- circle::TensorType::TensorType_FLOAT32);
- cgen.setInputsAndOutputs({lhs, rhs}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 3, 2, 4}, {2, 3, 1, 4}}, {{0, 1, 0, 1}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Cast_InvalidInputCount0)
-{
- CircleGen cgen;
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
- cgen.addOperatorCast({{}, {out}}, circle::TensorType::TensorType_FLOAT32,
- circle::TensorType::TensorType_INT32);
- cgen.setInputsAndOutputs({}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Cast_InvalidInputCount2)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
- int out = cgen.addTensor({{1, 2, 2, 3}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorCast({{lhs, rhs}, {out}}, circle::TensorType::TensorType_INT32,
- circle::TensorType::TensorType_FLOAT32);
- cgen.setInputsAndOutputs({lhs, rhs}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Cast_InvalidOutputCount0)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
- cgen.addOperatorCast({{in}, {}}, circle::TensorType::TensorType_INT32,
- circle::TensorType::TensorType_FLOAT32);
- cgen.setInputsAndOutputs({in}, {});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Cast_InvalidOutputCount2)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
- int out1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out2 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
- cgen.addOperatorCast({{in}, {out1, out2}}, circle::TensorType::TensorType_INT32,
- circle::TensorType::TensorType_FLOAT32);
- cgen.setInputsAndOutputs({in}, {out1, out2});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Concat.cc b/tests/nnfw_api/src/one_op_tests/Concat.cc
deleted file mode 100644
index 2ef1185d4..000000000
--- a/tests/nnfw_api/src/one_op_tests/Concat.cc
+++ /dev/null
@@ -1,210 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_Concat_ShareSubTensor)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int shared_subtensor = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int concat_out = cgen.addTensor({{1, 2, 2, 2}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> padding_data{0, 0, 1, 1, 1, 1, 0, 0};
- uint32_t padding_buf = cgen.addBuffer(padding_data);
- int padding = cgen.addTensor({{4, 2}, circle::TensorType::TensorType_INT32, padding_buf});
- int pad_out = cgen.addTensor({{1, 4, 4, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorAdd({{lhs, rhs}, {shared_subtensor}}, circle::ActivationFunctionType_NONE);
- cgen.addOperatorConcatenation({{rhs, shared_subtensor}, {concat_out}}, 3,
- circle::ActivationFunctionType_NONE);
- cgen.addOperatorPad({{shared_subtensor, padding}, {pad_out}});
- cgen.setInputsAndOutputs({lhs, rhs}, {pad_out, concat_out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>(
- {{1, 3, 2, 4}, {5, 4, 7, 4}},
- {{0, 0, 0, 0, 0, 6, 7, 0, 0, 9, 8, 0, 0, 0, 0, 0}, {5, 6, 4, 7, 7, 9, 4, 8}}));
- _context->setBackends({"acl_cl", "acl_neon"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Concat)
-{
- CircleGen cgen;
-
- int input1 = cgen.addTensor({{2, 3}, circle::TensorType::TensorType_FLOAT32});
- int input2 = cgen.addTensor({{2, 3}, circle::TensorType::TensorType_FLOAT32});
- int output = cgen.addTensor({{4, 3}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorConcatenation({{input1, input2}, {output}}, 0,
- circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({input1, input2}, {output});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 2, 3, 4, 5, 6}, {7, 8, 9, 10, 11, 12}},
- {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}}));
- _context->setBackends({"cpu;acl_cl"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Concat_Subtensor_4D)
-{
- CircleGen cgen;
- int in1 = cgen.addTensor({{1, 1, 1, 20}, circle::TensorType::TensorType_FLOAT32});
- int in2 = cgen.addTensor({{1, 1, 1, 10}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> axis_data{3};
- uint32_t axis_buf = cgen.addBuffer(axis_data);
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, axis_buf});
-
- int s_out1 = cgen.addTensor({{1, 1, 1, 5}, circle::TensorType::TensorType_FLOAT32});
- int s_out2 = cgen.addTensor({{1, 1, 1, 5}, circle::TensorType::TensorType_FLOAT32});
- int s_out3 = cgen.addTensor({{1, 1, 1, 5}, circle::TensorType::TensorType_FLOAT32});
- int s_out4 = cgen.addTensor({{1, 1, 1, 5}, circle::TensorType::TensorType_FLOAT32});
-
- int c_out1 = cgen.addTensor({{1, 1, 1, 10}, circle::TensorType::TensorType_FLOAT32});
- int c_out2 = cgen.addTensor({{1, 1, 1, 10}, circle::TensorType::TensorType_FLOAT32});
- int c_out3 = cgen.addTensor({{1, 1, 1, 10}, circle::TensorType::TensorType_FLOAT32});
-
- int a_out1 = cgen.addTensor({{1, 1, 1, 10}, circle::TensorType::TensorType_FLOAT32});
- int a_out2 = cgen.addTensor({{1, 1, 1, 10}, circle::TensorType::TensorType_FLOAT32});
- int a_out3 = cgen.addTensor({{1, 1, 1, 10}, circle::TensorType::TensorType_FLOAT32});
-
- int final_out = cgen.addTensor({{1, 1, 1, 35}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorSplit({{axis, in1}, {s_out1, s_out2, s_out3, s_out4}}, 4);
-
- cgen.addOperatorConcatenation({{s_out1, s_out2}, {c_out1}}, 3,
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
- cgen.addOperatorConcatenation({{s_out1, s_out3}, {c_out2}}, 3,
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
- cgen.addOperatorConcatenation({{s_out1, s_out4}, {c_out3}}, 3,
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
-
- cgen.addOperatorAdd({{c_out1, in2}, {a_out1}},
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
- cgen.addOperatorAdd({{c_out2, in2}, {a_out2}},
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
- cgen.addOperatorAdd({{c_out3, in2}, {a_out3}},
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
-
- cgen.addOperatorConcatenation({{s_out1, a_out1, a_out2, a_out3}, {final_out}}, 3,
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
-
- cgen.setInputsAndOutputs({in1, in2}, {s_out1, s_out2, s_out3, s_out4, c_out1, c_out2, c_out3,
- a_out1, a_out2, a_out3, final_out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>(
- {
- // inputs
- {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, // in1
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} // in2
- },
- {
- // outputs
- {1, 2, 3, 4, 5}, // s_out1
- {6, 7, 8, 9, 10}, // s_out2
- {11, 12, 13, 14, 15}, // s_out3
- {16, 17, 18, 19, 20}, // s_out4
- {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, // c_out1
- {1, 2, 3, 4, 5, 11, 12, 13, 14, 15}, // c_out2
- {1, 2, 3, 4, 5, 16, 17, 18, 19, 20}, // c_out3
- {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, // a_out1
- {1, 2, 3, 4, 5, 11, 12, 13, 14, 15}, // a_out2
- {1, 2, 3, 4, 5, 16, 17, 18, 19, 20}, // a_out3
- {1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3,
- 4, 5, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 16, 17, 18, 19, 20} // final_out
- }));
- _context->setBackends({"acl_cl"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Concat_Subtensor_2D)
-{
- CircleGen cgen;
- int in1 = cgen.addTensor({{1, 4}, circle::TensorType::TensorType_FLOAT32});
- int in2 = cgen.addTensor({{1, 2}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> axis_data{1};
- uint32_t axis_buf = cgen.addBuffer(axis_data);
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, axis_buf});
-
- int s_out1 = cgen.addTensor({{1, 1}, circle::TensorType::TensorType_FLOAT32});
- int s_out2 = cgen.addTensor({{1, 1}, circle::TensorType::TensorType_FLOAT32});
- int s_out3 = cgen.addTensor({{1, 1}, circle::TensorType::TensorType_FLOAT32});
- int s_out4 = cgen.addTensor({{1, 1}, circle::TensorType::TensorType_FLOAT32});
-
- int c_out1 = cgen.addTensor({{1, 2}, circle::TensorType::TensorType_FLOAT32});
- int c_out2 = cgen.addTensor({{1, 2}, circle::TensorType::TensorType_FLOAT32});
- int c_out3 = cgen.addTensor({{1, 2}, circle::TensorType::TensorType_FLOAT32});
-
- int a_out1 = cgen.addTensor({{1, 2}, circle::TensorType::TensorType_FLOAT32});
- int a_out2 = cgen.addTensor({{1, 2}, circle::TensorType::TensorType_FLOAT32});
- int a_out3 = cgen.addTensor({{1, 2}, circle::TensorType::TensorType_FLOAT32});
-
- int final_out = cgen.addTensor({{1, 7}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorSplit({{axis, in1}, {s_out1, s_out2, s_out3, s_out4}}, 4);
-
- cgen.addOperatorConcatenation({{s_out1, s_out2}, {c_out1}}, 1,
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
- cgen.addOperatorConcatenation({{s_out1, s_out3}, {c_out2}}, 1,
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
- cgen.addOperatorConcatenation({{s_out1, s_out4}, {c_out3}}, 1,
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
-
- cgen.addOperatorAdd({{c_out1, in2}, {a_out1}},
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
- cgen.addOperatorAdd({{c_out2, in2}, {a_out2}},
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
- cgen.addOperatorAdd({{c_out3, in2}, {a_out3}},
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
-
- cgen.addOperatorConcatenation({{s_out1, a_out1, a_out2, a_out3}, {final_out}}, 1,
- circle::ActivationFunctionType::ActivationFunctionType_NONE);
-
- cgen.setInputsAndOutputs({in1, in2}, {s_out1, s_out2, s_out3, s_out4, c_out1, c_out2, c_out3,
- a_out1, a_out2, a_out3, final_out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>(
- {
- // inputs
- {1, 2, 3, 4}, // in1
- {0, 0} // in2
- },
- {
- // outputs
- {1}, // s_out1
- {2}, // s_out2
- {3}, // s_out3
- {4}, // s_out4
- {1, 2}, // c_out1
- {1, 3}, // c_out2
- {1, 4}, // c_out3
- {1, 2}, // a_out1
- {1, 3}, // a_out2
- {1, 4}, // a_out3
- {1, 1, 2, 1, 3, 1, 4} // final_out
- }));
- _context->setBackends({"acl_cl"});
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Cos.cc b/tests/nnfw_api/src/one_op_tests/Cos.cc
deleted file mode 100644
index 03944746a..000000000
--- a/tests/nnfw_api/src/one_op_tests/Cos.cc
+++ /dev/null
@@ -1,50 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_Cos)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorCos({{in}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- const float pi = 3.141592653589793;
- _context->addTestCase(uniformTCD<float>({{0, pi / 2, pi, 7}}, {{1, 0, -1, 0.75390225434}}));
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Cos_TwoOperand)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out2 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorCos({{lhs, rhs}, {out1, out2}});
- cgen.setInputsAndOutputs({lhs, rhs}, {out1, out2});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Equal.cc b/tests/nnfw_api/src/one_op_tests/Equal.cc
deleted file mode 100644
index 54dcbee12..000000000
--- a/tests/nnfw_api/src/one_op_tests/Equal.cc
+++ /dev/null
@@ -1,69 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_Equal)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_BOOL});
- cgen.addOperatorEqual({{lhs, rhs}, {out}});
- cgen.setInputsAndOutputs({lhs, rhs}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<float>{0.1, 0.3, 0.5, 0.7});
- tcd.addInput(std::vector<float>{0.1, 0.2, 0.3, 0.4});
- tcd.addOutput(std::vector<bool>{true, false, false, false});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Equal_DifferentType)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_BOOL});
- cgen.addOperatorEqual({{lhs, rhs}, {out}});
- cgen.setInputsAndOutputs({lhs, rhs}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Equal_InvalidType)
-{
- CircleGen cgen;
- int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
- cgen.addOperatorEqual({{lhs, rhs}, {out}});
- cgen.setInputsAndOutputs({lhs, rhs}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/FullyConnected.cc b/tests/nnfw_api/src/one_op_tests/FullyConnected.cc
deleted file mode 100644
index 58bc830ef..000000000
--- a/tests/nnfw_api/src/one_op_tests/FullyConnected.cc
+++ /dev/null
@@ -1,90 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_FullyConnected)
-{
- CircleGen cgen;
- // clang-format off
- std::vector<float> weight_data{ 1, 0, 0, 1,
- 2, 0, 0, -1,
- 3, 0, 0, 2,
- 4, 0, 0, 1,
- 1, 0, 0, 1,
- 2, 0, 0, -1,
- 3, 0, 0, 2,
- 4, 0, 0, 1,
- 1, 0, 0, 1,
- 2, 0, 0, -1,
- 3, 0, 0, 2,
- 4, 0, 0, 1,
- 1, 0, 0, 1,
- 2, 0, 0, -1,
- 3, 0, 0, 2,
- 4, 0, 0, 1 };
- std::vector<float> bias_data{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
- // clang-format on
- uint32_t weight_buf = cgen.addBuffer(weight_data);
- uint32_t bias_buf = cgen.addBuffer(bias_data);
- int input = cgen.addTensor({{1, 4}, circle::TensorType::TensorType_FLOAT32});
- int weight = cgen.addTensor({{16, 4}, circle::TensorType::TensorType_FLOAT32, weight_buf});
- int bias = cgen.addTensor({{16}, circle::TensorType::TensorType_FLOAT32, bias_buf});
- int output = cgen.addTensor({{1, 16}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorFullyConnected({{input, weight, bias}, {output}});
- cgen.setInputsAndOutputs({input}, {output});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(
- uniformTCD<float>({{1, 3, 2, 1}}, {{2, 1, 5, 5, 2, 1, 5, 5, 2, 1, 5, 5, 2, 1, 5, 6}}));
- _context->setBackends({"cpu", "acl_neon"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_FullyConnected16x1)
-{
- CircleGen cgen;
- // clang-format off
- std::vector<float> weight_data{ 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
- 1, -1, 2, 1, 1, -1, 2, 1, 1, -1, 2, 1, 1, -1, 2, 1};
- std::vector<float> bias_data{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
- // clang-format on
- uint32_t weight_buf = cgen.addBuffer(weight_data);
- uint32_t bias_buf = cgen.addBuffer(bias_data);
- int input = cgen.addTensor({{1, 4}, circle::TensorType::TensorType_FLOAT32});
- CircleGen::SparsityParams sp{
- {0, 1, 2, 3},
- {0, 1},
- {{CircleGen::SparseDimensionType::DimensionType_DENSE, 1},
- {CircleGen::SparseDimensionType::DimensionType_SPARSE_CSR, {0, 2}, {0, 3}},
- {CircleGen::SparseDimensionType::DimensionType_DENSE, 16},
- {CircleGen::SparseDimensionType::DimensionType_DENSE, 1}}};
- int weight = cgen.addTensor({{16, 4}, circle::TensorType::TensorType_FLOAT32, weight_buf}, sp);
- int bias = cgen.addTensor({{16}, circle::TensorType::TensorType_FLOAT32, bias_buf});
- int output = cgen.addTensor({{1, 16}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorFullyConnected({{input, weight, bias}, {output}});
- cgen.setInputsAndOutputs({input}, {output});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(
- uniformTCD<float>({{1, 3, 2, 1}}, {{2, 1, 5, 5, 2, 1, 5, 5, 2, 1, 5, 5, 2, 1, 5, 6}}));
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/If.cc b/tests/nnfw_api/src/one_op_tests/If.cc
deleted file mode 100644
index 4ec294223..000000000
--- a/tests/nnfw_api/src/one_op_tests/If.cc
+++ /dev/null
@@ -1,132 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_If)
-{
- // The model looks just like the below pseudocode
- //
- // function model(x)
- // {
- // if (x < 0.0)
- // return -100.0;
- // else
- // return 100.0;
- // }
-
- CircleGen cgen;
-
- // constant buffers
- std::vector<float> comp_data{0.0};
- uint32_t comp_buf = cgen.addBuffer(comp_data);
- std::vector<float> then_data{-100};
- uint32_t then_buf = cgen.addBuffer(then_data);
- std::vector<float> else_data{100};
- uint32_t else_buf = cgen.addBuffer(else_data);
-
- // primary subgraph
- {
- int x = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int comp = cgen.addTensor({{1}, circle::TensorType_FLOAT32, comp_buf});
- int cond = cgen.addTensor({{1}, circle::TensorType_BOOL});
- cgen.addOperatorLess({{x, comp}, {cond}});
-
- int ret = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- cgen.addOperatorIf({{cond}, {ret}}, 1, 2);
-
- cgen.setInputsAndOutputs({x}, {ret});
- }
-
- // then subgraph
- {
- cgen.nextSubgraph();
- int ret = cgen.addTensor({{1}, circle::TensorType_FLOAT32, then_buf});
- cgen.setInputsAndOutputs({}, {ret});
- }
-
- // else subgraph
- {
- cgen.nextSubgraph();
- int ret = cgen.addTensor({{1}, circle::TensorType_FLOAT32, else_buf});
- cgen.setInputsAndOutputs({}, {ret});
- }
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{-1.0}}, {{-100.0}}));
- _context->addTestCase(uniformTCD<float>({{1.0}}, {{100.0}}));
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-class IfWrongSubgraphIndex : public GenModelTest,
- public ::testing::WithParamInterface<std::pair<int, int>>
-{
-};
-
-TEST_P(IfWrongSubgraphIndex, neg_Test)
-{
- // These values must be less than 0 or greater than 2
- int then_subg = GetParam().first;
- int else_subg = GetParam().second;
-
- // When If operation's subgraph index is invalid
-
- CircleGen cgen;
-
- // constant buffers
- std::vector<float> then_data{-100};
- uint32_t then_buf = cgen.addBuffer(then_data);
- std::vector<float> else_data{100};
- uint32_t else_buf = cgen.addBuffer(else_data);
-
- // primary subgraph
- {
- int x = cgen.addTensor({{1}, circle::TensorType_BOOL});
- int ret = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- cgen.addOperatorIf({{x}, {ret}}, then_subg, else_subg);
-
- cgen.setInputsAndOutputs({x}, {ret});
- }
-
- // then subgraph
- {
- cgen.nextSubgraph();
- int ret = cgen.addTensor({{1}, circle::TensorType_FLOAT32, then_buf});
- cgen.setInputsAndOutputs({}, {ret});
- }
-
- // else subgraph
- {
- cgen.nextSubgraph();
- int ret = cgen.addTensor({{1}, circle::TensorType_FLOAT32, else_buf});
- cgen.setInputsAndOutputs({}, {ret});
- }
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-INSTANTIATE_TEST_CASE_P(GenModelTest, IfWrongSubgraphIndex,
- ::testing::Values(std::make_pair(99, 2), std::make_pair(-1, 2),
- std::make_pair(1, 99), std::make_pair(1, -99),
- std::make_pair(-99, 99)));
diff --git a/tests/nnfw_api/src/one_op_tests/InstanceNorm.cc b/tests/nnfw_api/src/one_op_tests/InstanceNorm.cc
deleted file mode 100644
index 6569ced21..000000000
--- a/tests/nnfw_api/src/one_op_tests/InstanceNorm.cc
+++ /dev/null
@@ -1,57 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_InstanceNorm)
-{
- CircleGen cgen;
- uint32_t beta_buf = cgen.addBuffer(std::vector<float>{1});
- uint32_t gamma_buf = cgen.addBuffer(std::vector<float>{2});
- int beta = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, beta_buf});
- int gamma = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, gamma_buf});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorInstanceNorm({{in, beta, gamma}, {out}}, 0, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 1, 1, 1}}, {{2, 2, 2, 2}}));
- _context->setBackends({"acl_cl", "acl_neon"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_InstanceNorm_InvalidActivation)
-{
- CircleGen cgen;
- uint32_t beta_buf = cgen.addBuffer(std::vector<float>{1});
- uint32_t gamma_buf = cgen.addBuffer(std::vector<float>{2});
- int beta = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, beta_buf});
- int gamma = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, gamma_buf});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorInstanceNorm({{in, beta, gamma}, {out}}, 0,
- static_cast<circle::ActivationFunctionType>(128) /* Invalid value*/);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/L2Normalization.cc b/tests/nnfw_api/src/one_op_tests/L2Normalization.cc
deleted file mode 100644
index 8e0ae6df2..000000000
--- a/tests/nnfw_api/src/one_op_tests/L2Normalization.cc
+++ /dev/null
@@ -1,36 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_L2Normalization)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 3}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 3}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorL2Normalization({{in}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(
- uniformTCD<float>({{0, 3, 4, 0, 5, 12, 0, 8, 15, 0, 7, 24}},
- {{0, 0.6, 0.8, 0, 0.38461539149284363, 0.92307698726654053, 0,
- 0.47058823704719543, 0.88235294818878174, 0, 0.28, 0.96}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/LeakyRelu.cc b/tests/nnfw_api/src/one_op_tests/LeakyRelu.cc
deleted file mode 100644
index e17f34fb3..000000000
--- a/tests/nnfw_api/src/one_op_tests/LeakyRelu.cc
+++ /dev/null
@@ -1,48 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_LeakyRelu)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 3}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{2, 3}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorLeakyRelu({{in}, {out}}, 0.5);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(
- uniformTCD<float>({{0, 1.0, 3.0, 1.0, -1.0, -2.0f}}, {{0, 1.0, 3.0, 1.0, -0.5, -1.0}}));
- _context->setBackends({"acl_cl", "acl_neon"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_LeakyRelu_InvalidType)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 3}, circle::TensorType::TensorType_UINT8});
- int out = cgen.addTensor({{2, 3}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorLeakyRelu({{in}, {out}}, 0.5);
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/LogSoftmax.cc b/tests/nnfw_api/src/one_op_tests/LogSoftmax.cc
deleted file mode 100644
index b34b2e83f..000000000
--- a/tests/nnfw_api/src/one_op_tests/LogSoftmax.cc
+++ /dev/null
@@ -1,51 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_LogSoftmax)
-{
- // NOTE For tf lite the params are fixed as:
- // beta = 1.0, axis = -1
-
- CircleGen cgen;
- int in = cgen.addTensor({{1, 1, 1, 4, 2}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 1, 1, 4, 2}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorLogSoftmax({{in}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"cpu"});
- _context->addTestCase(uniformTCD<float>(
- {{0, -6, 2, 4, 3, -2, 10, 1}},
- {{-.00247565, -6.00247, -2.12692, -.126928, -.00671534, -5.00671, -.000123374, -9.00012}}));
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_LogSoftmax_InvalidModel)
-{
- CircleGen cgen;
- int out = cgen.addTensor({{4, 2}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorLogSoftmax({{}, {out}}); // No input tensor
- cgen.setInputsAndOutputs({}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/OneHot.cc b/tests/nnfw_api/src/one_op_tests/OneHot.cc
deleted file mode 100644
index e688e790d..000000000
--- a/tests/nnfw_api/src/one_op_tests/OneHot.cc
+++ /dev/null
@@ -1,201 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_OneHot_OffValueToConst)
-{
- CircleGen cgen;
- std::vector<int32_t> depth_data{3};
- uint32_t depth_buf = cgen.addBuffer(depth_data);
- std::vector<float> off_value_data{0};
- uint32_t off_value_buf = cgen.addBuffer(off_value_data);
- int indices = cgen.addTensor({{1, 2, 2}, circle::TensorType::TensorType_INT32});
- int depth = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, depth_buf});
- int on_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int off_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, off_value_buf});
- int axis = 2;
- int out = cgen.addTensor({{1, 2, 3, 2}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorOneHot({{indices, depth, on_value, off_value}, {out}}, axis);
- cgen.setInputsAndOutputs({indices, on_value}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<int32_t>{1, 2, 0, 2});
- tcd.addInput(std::vector<float>{1});
- tcd.addOutput(std::vector<float>{0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_OneHot_OffValueToNotZero)
-{
- CircleGen cgen;
- std::vector<int32_t> depth_data{3};
- uint32_t depth_buf = cgen.addBuffer(depth_data);
- int indices = cgen.addTensor({{1, 2, 2}, circle::TensorType::TensorType_INT32});
- int depth = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, depth_buf});
- int on_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int off_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int axis = 2;
- int out = cgen.addTensor({{1, 2, 3, 2}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorOneHot({{indices, depth, on_value, off_value}, {out}}, axis);
- cgen.setInputsAndOutputs({indices, on_value, off_value}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<int32_t>{1, 2, 0, 2});
- tcd.addInput(std::vector<float>{1});
- tcd.addInput(std::vector<float>{-1});
- tcd.addOutput(std::vector<float>{-1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_OneHot_IndicesValueToNeg_OffValueToConst)
-{
- CircleGen cgen;
- std::vector<int32_t> depth_data{3};
- uint32_t depth_buf = cgen.addBuffer(depth_data);
- std::vector<float> off_value_data{0};
- uint32_t off_value_buf = cgen.addBuffer(off_value_data);
- int indices = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_INT32});
- int depth = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, depth_buf});
- int on_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int off_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, off_value_buf});
- int axis = 2;
- int out = cgen.addTensor({{2, 2, 3}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorOneHot({{indices, depth, on_value, off_value}, {out}}, axis);
- cgen.setInputsAndOutputs({indices, on_value}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<int32_t>{1, 2, 0, -1});
- tcd.addInput(std::vector<float>{1});
- tcd.addOutput(std::vector<float>{0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_OneHot_IndicesValueToNeg_OffValueToVar)
-{
- CircleGen cgen;
- std::vector<int32_t> depth_data{3};
- uint32_t depth_buf = cgen.addBuffer(depth_data);
- int indices = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_INT32});
- int depth = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, depth_buf});
- int on_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int off_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int axis = 2;
- int out = cgen.addTensor({{2, 2, 3}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorOneHot({{indices, depth, on_value, off_value}, {out}}, axis);
- cgen.setInputsAndOutputs({indices, on_value, off_value}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<int32_t>{1, 2, 0, -1});
- tcd.addInput(std::vector<float>{1});
- tcd.addInput(std::vector<float>{0});
- tcd.addOutput(std::vector<float>{0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_OneHot_OneOperand)
-{
- CircleGen cgen;
- int indices = cgen.addTensor({{1, 2, 2}, circle::TensorType::TensorType_INT32});
- int axis = 2;
- int out = cgen.addTensor({{1, 2, 3, 2}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorOneHot({{indices}, {out}}, axis);
- cgen.setInputsAndOutputs({indices}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_OneHot_TwoOperands)
-{
- CircleGen cgen;
- std::vector<int> depth_data{3};
- uint32_t depth_buf = cgen.addBuffer(depth_data);
- int indices = cgen.addTensor({{1, 2, 2}, circle::TensorType::TensorType_INT32});
- int depth = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, depth_buf});
- int axis = 2;
- int out = cgen.addTensor({{1, 2, 3, 2}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorOneHot({{indices, depth}, {out}}, axis);
- cgen.setInputsAndOutputs({indices}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_OneHot_ThreeOperands)
-{
- CircleGen cgen;
- std::vector<int> depth_data{3};
- uint32_t depth_buf = cgen.addBuffer(depth_data);
- int indices = cgen.addTensor({{1, 2, 2}, circle::TensorType::TensorType_INT32});
- int depth = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, depth_buf});
- int on_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int axis = 2;
- int out = cgen.addTensor({{1, 2, 3, 2}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorOneHot({{indices, depth, on_value}, {out}}, axis);
- cgen.setInputsAndOutputs({indices, on_value}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_OneHot_InvalidAxis)
-{
- CircleGen cgen;
- std::vector<int> depth_data{3};
- uint32_t depth_buf = cgen.addBuffer(depth_data);
- int indices = cgen.addTensor({{1, 2, 2}, circle::TensorType::TensorType_INT32});
- int depth = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, depth_buf});
- int on_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int off_value = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
- int axis = 4;
- int out = cgen.addTensor({{1, 2, 3, 2}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorOneHot({{indices, depth, on_value, off_value}, {out}}, axis);
- cgen.setInputsAndOutputs({indices, on_value, off_value}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Pad.cc b/tests/nnfw_api/src/one_op_tests/Pad.cc
deleted file mode 100644
index 63d02ab88..000000000
--- a/tests/nnfw_api/src/one_op_tests/Pad.cc
+++ /dev/null
@@ -1,93 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_Pad)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> padding_data{0, 0, 1, 1, 1, 1, 0, 0};
- uint32_t padding_buf = cgen.addBuffer(padding_data);
- int padding = cgen.addTensor({{4, 2}, circle::TensorType::TensorType_INT32, padding_buf});
- int out = cgen.addTensor({{1, 4, 4, 1}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorPad({{in, padding}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(
- uniformTCD<float>({{1, 2, 3, 4}}, {{0, 0, 0, 0, 0, 1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 0}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Pad_InvalidPadRank)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> padding_data{1, 1, 1, 1};
- uint32_t padding_buf = cgen.addBuffer(padding_data);
- int padding = cgen.addTensor({{4}, circle::TensorType::TensorType_INT32, padding_buf});
- int out = cgen.addTensor({{1, 4, 4, 1}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorPad({{in, padding}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Pad_InvalidPadDim0)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> padding_data{1, 1, 1, 1};
- uint32_t padding_buf = cgen.addBuffer(padding_data);
- int padding = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_INT32, padding_buf});
- int out = cgen.addTensor({{1, 4, 4, 1}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorPad({{in, padding}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Pad_InvalidPadDim1)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> padding_data{1, 1, 1, 1};
- uint32_t padding_buf = cgen.addBuffer(padding_data);
- int padding = cgen.addTensor({{4, 1}, circle::TensorType::TensorType_INT32, padding_buf});
- int out = cgen.addTensor({{2, 2, 2, 2}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorPad({{in, padding}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/PadV2.cc b/tests/nnfw_api/src/one_op_tests/PadV2.cc
deleted file mode 100644
index e613fe282..000000000
--- a/tests/nnfw_api/src/one_op_tests/PadV2.cc
+++ /dev/null
@@ -1,114 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_PadV2)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> padding_data{0, 0, 1, 1, 1, 1, 0, 0};
- uint32_t padding_buf = cgen.addBuffer(padding_data);
- int padding = cgen.addTensor({{4, 2}, circle::TensorType::TensorType_INT32, padding_buf});
- std::vector<float> padding_value_data{3.0};
- uint32_t padding_value_buf = cgen.addBuffer(padding_value_data);
- int padding_value =
- cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, padding_value_buf});
-
- int out = cgen.addTensor({{1, 4, 4, 1}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorPadV2({{in, padding, padding_value}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(
- uniformTCD<float>({{1, 2, 3, 4}}, {{3, 3, 3, 3, 3, 1, 2, 3, 3, 3, 4, 3, 3, 3, 3, 3}}));
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_PadV2_InvalidPadRank)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> padding_data{1, 1, 1, 1};
- uint32_t padding_buf = cgen.addBuffer(padding_data);
- int padding = cgen.addTensor({{4}, circle::TensorType::TensorType_INT32, padding_buf});
- std::vector<float> padding_value_data{3.0};
- uint32_t padding_value_buf = cgen.addBuffer(padding_value_data);
- int padding_value =
- cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, padding_value_buf});
-
- int out = cgen.addTensor({{1, 4, 4, 1}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorPad({{in, padding, padding_value}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_PadV2_InvalidPadDim0)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> padding_data{1, 1, 1, 1};
- uint32_t padding_buf = cgen.addBuffer(padding_data);
- int padding = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_INT32, padding_buf});
- std::vector<float> padding_value_data{3.0};
- uint32_t padding_value_buf = cgen.addBuffer(padding_value_data);
- int padding_value =
- cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, padding_value_buf});
-
- int out = cgen.addTensor({{1, 4, 4, 1}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorPad({{in, padding, padding_value}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_PadV2_InvalidPadDim1)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> padding_data{1, 1, 1, 1};
- uint32_t padding_buf = cgen.addBuffer(padding_data);
- int padding = cgen.addTensor({{4, 1}, circle::TensorType::TensorType_INT32, padding_buf});
- std::vector<float> padding_value_data{3.0};
- uint32_t padding_value_buf = cgen.addBuffer(padding_value_data);
- int padding_value =
- cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32, padding_value_buf});
-
- int out = cgen.addTensor({{2, 2, 2, 2}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorPad({{in, padding, padding_value}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Rank.cc b/tests/nnfw_api/src/one_op_tests/Rank.cc
deleted file mode 100644
index 7af1b4540..000000000
--- a/tests/nnfw_api/src/one_op_tests/Rank.cc
+++ /dev/null
@@ -1,53 +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.
- */
-
-#include "GenModelTest.h"
-
-// WORKAROUND Handle int32_t type input/output
-TEST_F(GenModelTest, OneOp_Rank)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 3, 3, 2}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32});
-
- cgen.addOperatorRank({{in}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<float>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18});
- tcd.addOutput(std::vector<int32_t>{4});
- _context->addTestCase(tcd);
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Rank_Int32)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 3, 3, 2}, circle::TensorType::TensorType_INT32});
- int out = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32});
-
- // TODO handle many type in addTestCase
- cgen.addOperatorRank({{in}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<int32_t>(
- {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}}, {{4}}));
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/ResizeBilinear.cc b/tests/nnfw_api/src/one_op_tests/ResizeBilinear.cc
deleted file mode 100644
index 555d074a3..000000000
--- a/tests/nnfw_api/src/one_op_tests/ResizeBilinear.cc
+++ /dev/null
@@ -1,75 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_ResizeBilinear_SizeToConst)
-{
- CircleGen cgen;
- std::vector<int32_t> size_data{3, 3};
- uint32_t size_buf = cgen.addBuffer(size_data);
- int size = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, size_buf});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 3, 3, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorResizeBilinear({{in, size}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>(
- {{1, 1, 2, 2}}, {{1, 1, 1, 1.666666667, 1.666666667, 1.666666667, 2, 2, 2}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_ResizeBilinear_SizeToVar)
-{
- CircleGen cgen;
- int size = cgen.addTensor({{2}, circle::TensorType::TensorType_INT32});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorResizeBilinear({{in, size}, {out}});
- cgen.setInputsAndOutputs({in, size}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<int32_t>{3, 3});
- tcd.addInput(std::vector<float>{1, 1, 2, 2});
- tcd.addOutput(std::vector<float>{1, 1, 1, 1.666666667, 1.666666667, 1.666666667, 2, 2, 2});
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_ResizeBilinear_InvalidSizeVal)
-{
- CircleGen cgen;
- std::vector<int32_t> size_data{-3, 3};
- uint32_t size_buf = cgen.addBuffer(size_data);
- int size = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, size_buf});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorResizeBilinear({{in, size}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/ResizeNearestNeighbor.cc b/tests/nnfw_api/src/one_op_tests/ResizeNearestNeighbor.cc
deleted file mode 100644
index d1617c33a..000000000
--- a/tests/nnfw_api/src/one_op_tests/ResizeNearestNeighbor.cc
+++ /dev/null
@@ -1,39 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_ResizeNearestNeighbor)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{1, 2, 2, 2}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> size_data{3, 3};
- uint32_t size_buf = cgen.addBuffer(size_data);
- int size = cgen.addTensor({{2}, circle::TensorType::TensorType_INT32, size_buf});
-
- int out = cgen.addTensor({{1, 3, 3, 2}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorResizeNearestNeighbor({{in, size}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(
- uniformTCD<float>({{3, 4, 6, 10, 9, 10, 12, 16}},
- {{3, 4, 3, 4, 6, 10, 3, 4, 3, 4, 6, 10, 9, 10, 9, 10, 12, 16}}));
- _context->setBackends({"acl_cl"});
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Reverse.cc b/tests/nnfw_api/src/one_op_tests/Reverse.cc
deleted file mode 100644
index ef0c5fe82..000000000
--- a/tests/nnfw_api/src/one_op_tests/Reverse.cc
+++ /dev/null
@@ -1,59 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_ReverseV2_3D)
-{
- CircleGen cgen;
-
- int in = cgen.addTensor({{4, 3, 2}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> axis_data{1};
- uint32_t axis_buf = cgen.addBuffer(axis_data);
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, axis_buf});
- int out = cgen.addTensor({{4, 3, 2}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorReverseV2({{in, axis}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "cpu"});
- _context->addTestCase(uniformTCD<float>(
- {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}},
- {{5, 6, 3, 4, 1, 2, 11, 12, 9, 10, 7, 8, 17, 18, 15, 16, 13, 14, 23, 24, 21, 22, 19, 20}}));
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_ReverseV2_1D)
-{
- CircleGen cgen;
-
- int in = cgen.addTensor({{4}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> axis_data{0};
- uint32_t axis_buf = cgen.addBuffer(axis_data);
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, axis_buf});
- int out = cgen.addTensor({{4}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorReverseV2({{in, axis}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "cpu"});
- _context->addTestCase(uniformTCD<float>({{1, 2, 3, 4}}, {{4, 3, 2, 1}}));
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Split.cc b/tests/nnfw_api/src/one_op_tests/Split.cc
deleted file mode 100644
index 1e91efec8..000000000
--- a/tests/nnfw_api/src/one_op_tests/Split.cc
+++ /dev/null
@@ -1,65 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_Split)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 4}, circle::TensorType::TensorType_FLOAT32});
- std::vector<int32_t> axis_data{1};
- uint32_t axis_buf = cgen.addBuffer(axis_data);
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32, axis_buf});
-
- int out1 = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_FLOAT32});
- int out2 = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorSplit({{axis, in}, {out1, out2}}, 2);
- cgen.setInputsAndOutputs({in}, {out1, out2});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(
- uniformTCD<float>({{1, 2, 3, 4, 5, 6, 7, 8}}, {{1, 2, 5, 6}, {3, 4, 7, 8}}));
- _context->setBackends({"cpu", "acl_cl", "acl_neon"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_SplitNonConstAxis)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 4}, circle::TensorType::TensorType_FLOAT32});
- int axis = cgen.addTensor({{1}, circle::TensorType::TensorType_INT32});
-
- int out1 = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_FLOAT32});
- int out2 = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_FLOAT32});
-
- cgen.addOperatorSplit({{axis, in}, {out1, out2}}, 2);
- cgen.setInputsAndOutputs({axis, in}, {out1, out2});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
-
- TestCaseData tcd;
- tcd.addInput(std::vector<int32_t>{1});
- tcd.addInput(std::vector<float>{1, 2, 3, 4, 5, 6, 7, 8});
- tcd.addOutput(std::vector<float>{1, 2, 5, 6});
- tcd.addOutput(std::vector<float>{3, 4, 7, 8});
-
- _context->addTestCase(tcd);
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/StridedSlice.cc b/tests/nnfw_api/src/one_op_tests/StridedSlice.cc
deleted file mode 100644
index fb29018d4..000000000
--- a/tests/nnfw_api/src/one_op_tests/StridedSlice.cc
+++ /dev/null
@@ -1,43 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_StridedSlice_LastDim)
-{
- CircleGen cgen;
- std::vector<int32_t> begin_data{0, 3};
- std::vector<int32_t> end_data{0, 6};
- std::vector<int32_t> strides_data{1, 1};
- uint32_t begin_buf = cgen.addBuffer(begin_data);
- uint32_t end_buf = cgen.addBuffer(end_data);
- uint32_t strides_buf = cgen.addBuffer(strides_data);
- int input = cgen.addTensor({{1, 6}, circle::TensorType::TensorType_FLOAT32});
- int begin = cgen.addTensor({{2}, circle::TensorType::TensorType_INT32, begin_buf});
- int end = cgen.addTensor({{2}, circle::TensorType::TensorType_INT32, end_buf});
- int strides = cgen.addTensor({{2}, circle::TensorType::TensorType_INT32, strides_buf});
- int out = cgen.addTensor({{1, 3}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorStridedSlice({{input, begin, end, strides}, {out}}, 1, 1);
- cgen.setInputsAndOutputs({input}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{1, 2, 3, 4, 5, 6}}, {{4, 5, 6}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Tile.cc b/tests/nnfw_api/src/one_op_tests/Tile.cc
deleted file mode 100644
index 5fa76fc6d..000000000
--- a/tests/nnfw_api/src/one_op_tests/Tile.cc
+++ /dev/null
@@ -1,136 +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.
- */
-
-#include "GenModelTest.h"
-
-TEST_F(GenModelTest, OneOp_Tile_ConstMul)
-{
- CircleGen cgen;
- std::vector<int32_t> mul_data{1, 2};
- uint32_t mul_buf = cgen.addBuffer(mul_data);
- int in = cgen.addTensor({{2, 3}, circle::TensorType::TensorType_FLOAT32});
- int mul = cgen.addTensor({{2}, circle::TensorType::TensorType_INT32, mul_buf});
- int out = cgen.addTensor({{2, 6}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTile({{in, mul}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(
- uniformTCD<float>({{1, 2, 3, 4, 5, 6}}, {{1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6}}));
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Tile_MulToConst)
-{
- CircleGen cgen;
- std::vector<int32_t> multiplies_data{2, 3, 1};
- uint32_t multiplies_buf = cgen.addBuffer(multiplies_data);
- int multiplies = cgen.addTensor({{3}, circle::TensorType::TensorType_INT32, multiplies_buf});
- int in = cgen.addTensor({{1, 2, 3}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{2, 6, 3}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTile({{in, multiplies}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>(
- {{11, 12, 13, 21, 22, 23}},
- {{11, 12, 13, 21, 22, 23, 11, 12, 13, 21, 22, 23, 11, 12, 13, 21, 22, 23,
- 11, 12, 13, 21, 22, 23, 11, 12, 13, 21, 22, 23, 11, 12, 13, 21, 22, 23}}));
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Tile_MulToVar)
-{
- CircleGen cgen;
- int multiplies = cgen.addTensor({{3}, circle::TensorType::TensorType_INT32});
- int in = cgen.addTensor({{1, 2, 3}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{2, 6, 3}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTile({{in, multiplies}, {out}});
- cgen.setInputsAndOutputs({in, multiplies}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<float>{11, 12, 13, 21, 22, 23});
- tcd.addInput(std::vector<int32_t>{2, 3, 1});
- tcd.addOutput(std::vector<float>{11, 12, 13, 21, 22, 23, 11, 12, 13, 21, 22, 23,
- 11, 12, 13, 21, 22, 23, 11, 12, 13, 21, 22, 23,
- 11, 12, 13, 21, 22, 23, 11, 12, 13, 21, 22, 23});
- _context->addTestCase(tcd);
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Tile_VarMul)
-{
- CircleGen cgen;
- int in = cgen.addTensor({{2, 3}, circle::TensorType::TensorType_FLOAT32});
- int mul = cgen.addTensor({{2}, circle::TensorType::TensorType_INT32});
- int out = cgen.addTensor({{2, 6}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTile({{in, mul}, {out}});
- cgen.setInputsAndOutputs({in, mul}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<float>{1, 2, 3, 4, 5, 6});
- tcd.addInput(std::vector<int32_t>{1, 2});
- tcd.addOutput(std::vector<float>{1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6});
- _context->addTestCase(tcd);
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Tile)
-{
- CircleGen cgen;
- std::vector<int32_t> mul_data{1, 2, 1, 2};
- uint32_t mul_buf = cgen.addBuffer(mul_data);
- int in = cgen.addTensor({{2, 3}, circle::TensorType::TensorType_FLOAT32});
- // 2D multiples input is not supported
- int mul = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_INT32, mul_buf});
- int out = cgen.addTensor({{2, 6}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTile({{in, mul}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Tile_InvalidMulSize)
-{
- CircleGen cgen;
- std::vector<int32_t> multiplies_data{2, 6};
- uint32_t multiplies_buf = cgen.addBuffer(multiplies_data);
- int multiplies = cgen.addTensor({{2}, circle::TensorType::TensorType_INT32, multiplies_buf});
- int in = cgen.addTensor({{1, 2, 3}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{2, 6, 3}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTile({{in, multiplies}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/Transpose.cc b/tests/nnfw_api/src/one_op_tests/Transpose.cc
deleted file mode 100644
index f2e971198..000000000
--- a/tests/nnfw_api/src/one_op_tests/Transpose.cc
+++ /dev/null
@@ -1,145 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_Transpose_PermsToConst)
-{
- CircleGen cgen;
- std::vector<int32_t> perms_data{2, 0, 1, 3};
- uint32_t perms_buf = cgen.addBuffer(perms_data);
- int perms = cgen.addTensor({{4}, circle::TensorType::TensorType_INT32, perms_buf});
- int in = cgen.addTensor({{2, 3, 4, 5}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{2, 3, 4, 5}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTranspose({{in, perms}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>(
- {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
- 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
- 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
- 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119}},
- {{0, 1, 2, 3, 4, 20, 21, 22, 23, 24, 40, 41, 42, 43, 44, 60, 61, 62,
- 63, 64, 80, 81, 82, 83, 84, 100, 101, 102, 103, 104, 5, 6, 7, 8, 9, 25,
- 26, 27, 28, 29, 45, 46, 47, 48, 49, 65, 66, 67, 68, 69, 85, 86, 87, 88,
- 89, 105, 106, 107, 108, 109, 10, 11, 12, 13, 14, 30, 31, 32, 33, 34, 50, 51,
- 52, 53, 54, 70, 71, 72, 73, 74, 90, 91, 92, 93, 94, 110, 111, 112, 113, 114,
- 15, 16, 17, 18, 19, 35, 36, 37, 38, 39, 55, 56, 57, 58, 59, 75, 76, 77,
- 78, 79, 95, 96, 97, 98, 99, 115, 116, 117, 118, 119}}));
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Transpose_PermsToVar)
-{
- CircleGen cgen;
- int perms = cgen.addTensor({{4}, circle::TensorType::TensorType_INT32});
- int in = cgen.addTensor({{1, 2, 3, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 3, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTranspose({{in, perms}, {out}});
- cgen.setInputsAndOutputs({in, perms}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<float>{1, 2, 3, 4, 5, 6});
- tcd.addInput(std::vector<int32_t>{0, 2, 1, 3});
- tcd.addOutput(std::vector<float>{1, 4, 2, 5, 3, 6});
- _context->addTestCase(tcd);
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_Transpose_RegularTranspose)
-{
- CircleGen cgen;
- int perms = cgen.addTensor({{0}, circle::TensorType::TensorType_INT32});
- int in = cgen.addTensor({{1, 2, 3, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 3, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTranspose({{in, perms}, {out}});
- cgen.setInputsAndOutputs({in, perms}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- TestCaseData tcd;
- tcd.addInput(std::vector<float>{1, 2, 3, 4, 5, 6});
- tcd.addInput(std::vector<int32_t>{});
- tcd.addOutput(std::vector<float>{1, 4, 2, 5, 3, 6});
- _context->addTestCase(tcd);
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Transpose_InvalidPermsSize)
-{
- CircleGen cgen;
- std::vector<int32_t> perms_data{0, 1, 2};
- uint32_t perms_buf = cgen.addBuffer(perms_data);
- int perms = cgen.addTensor({{3}, circle::TensorType::TensorType_INT32, perms_buf});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTranspose({{in, perms}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Transpose_InvalidPermsVal)
-{
- CircleGen cgen;
- std::vector<int32_t> perms_data{-3, 3, 1, 2};
- uint32_t perms_buf = cgen.addBuffer(perms_data);
- int perms = cgen.addTensor({{4}, circle::TensorType::TensorType_INT32, perms_buf});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTranspose({{in, perms}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, neg_OneOp_Transpose_DuplicatedPermsVal)
-{
- CircleGen cgen;
- std::vector<int32_t> perms_data{3, 3, 1, 2};
- uint32_t perms_buf = cgen.addBuffer(perms_data);
- int perms = cgen.addTensor({{4}, circle::TensorType::TensorType_INT32, perms_buf});
- int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
- cgen.addOperatorTranspose({{in, perms}, {out}});
- cgen.setInputsAndOutputs({in}, {out});
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"acl_cl", "acl_neon", "cpu"});
- _context->expectFailCompile();
-
- SUCCEED();
-}
diff --git a/tests/nnfw_api/src/one_op_tests/While.cc b/tests/nnfw_api/src/one_op_tests/While.cc
deleted file mode 100644
index 8b909c29f..000000000
--- a/tests/nnfw_api/src/one_op_tests/While.cc
+++ /dev/null
@@ -1,195 +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.
- */
-
-#include "GenModelTest.h"
-
-#include <memory>
-
-TEST_F(GenModelTest, OneOp_While)
-{
- // The model looks just like the below pseudocode
- //
- // function model(x)
- // {
- // while (x < 100.0)
- // {
- // x = x + 10.0;
- // }
- // return x
- // }
-
- CircleGen cgen;
- std::vector<float> incr_data{10};
- uint32_t incr_buf = cgen.addBuffer(incr_data);
- std::vector<float> end_data{100};
- uint32_t end_buf = cgen.addBuffer(end_data);
-
- // primary subgraph
- {
- int x_in = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int x_out = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- cgen.addOperatorWhile({{x_in}, {x_out}}, 1, 2);
- cgen.setInputsAndOutputs({x_in}, {x_out});
- }
-
- // cond subgraph
- {
- cgen.nextSubgraph();
- int x = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int end = cgen.addTensor({{1}, circle::TensorType_FLOAT32, end_buf});
- int result = cgen.addTensor({{1}, circle::TensorType_BOOL});
- cgen.addOperatorLess({{x, end}, {result}});
- cgen.setInputsAndOutputs({x}, {result});
- }
-
- // body subgraph
- {
- cgen.nextSubgraph();
- int x_in = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int incr = cgen.addTensor({{1}, circle::TensorType_FLOAT32, incr_buf});
- int x_out = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- cgen.addOperatorAdd({{x_in, incr}, {x_out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({x_in}, {x_out});
- }
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{0}}, {{100}}));
- _context->addTestCase(uniformTCD<float>({{2}}, {{102}}));
- _context->addTestCase(uniformTCD<float>({{22}}, {{102}}));
- _context->addTestCase(uniformTCD<float>({{100}}, {{100}}));
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-TEST_F(GenModelTest, OneOp_While_TwoInputs)
-{
- // The model looks just like the below pseudocode
- //
- // function model(x, end)
- // {
- // while (x < end)
- // {
- // x = x + 10.0
- // }
- // return x
- // }
-
- CircleGen cgen;
- std::vector<float> incr_data{10};
- uint32_t incr_buf = cgen.addBuffer(incr_data);
-
- // primary subgraph
- {
- int x_in = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int x_out = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int end_in = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int end_out = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- cgen.addOperatorWhile({{x_in, end_in}, {x_out, end_out}}, 1, 2);
- cgen.setInputsAndOutputs({x_in, end_in}, {x_out});
- }
-
- // cond subgraph
- {
- cgen.nextSubgraph();
- int x = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int end = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int result = cgen.addTensor({{1}, circle::TensorType_BOOL});
- cgen.addOperatorLess({{x, end}, {result}});
- cgen.setInputsAndOutputs({x, end}, {result});
- }
-
- // body subgraph
- {
- cgen.nextSubgraph();
- int x_in = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int incr = cgen.addTensor({{1}, circle::TensorType_FLOAT32, incr_buf});
- int x_out = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int end = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- cgen.addOperatorAdd({{x_in, incr}, {x_out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({x_in, end}, {x_out, end});
- }
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->addTestCase(uniformTCD<float>({{0}, {20}}, {{20}}));
- _context->addTestCase(uniformTCD<float>({{5}, {30}}, {{35}}));
- _context->addTestCase(uniformTCD<float>({{20}, {10}}, {{20}}));
- _context->setBackends({"cpu"});
-
- SUCCEED();
-}
-
-class WhileWrongSubgraphIndex : public GenModelTest,
- public ::testing::WithParamInterface<std::pair<int, int>>
-{
-};
-
-TEST_P(WhileWrongSubgraphIndex, neg_Test)
-{
- // These values must be less than 0 or greater than 2
- int cond_subg = GetParam().first;
- int body_subg = GetParam().second;
-
- // When While operation's subgraph index is invalid
-
- CircleGen cgen;
-
- // constant buffers
- std::vector<float> incr_data{10};
- uint32_t incr_buf = cgen.addBuffer(incr_data);
-
- // primary subgraph
- {
- int x_in = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int x_out = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int end_in = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int end_out = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- cgen.addOperatorWhile({{x_in, end_in}, {x_out, end_out}}, cond_subg, body_subg);
- cgen.setInputsAndOutputs({x_in, end_in}, {x_out});
- }
-
- // cond subgraph
- {
- cgen.nextSubgraph();
- int x = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int end = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int result = cgen.addTensor({{1}, circle::TensorType_BOOL});
- cgen.addOperatorLess({{x, end}, {result}});
- cgen.setInputsAndOutputs({x, end}, {result});
- }
-
- // body subgraph
- {
- cgen.nextSubgraph();
- int x_in = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int incr = cgen.addTensor({{1}, circle::TensorType_FLOAT32, incr_buf});
- int x_out = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- int end = cgen.addTensor({{1}, circle::TensorType_FLOAT32});
- cgen.addOperatorAdd({{x_in, incr}, {x_out}}, circle::ActivationFunctionType_NONE);
- cgen.setInputsAndOutputs({x_in, end}, {x_out, end});
- }
-
- _context = std::make_unique<GenModelTestContext>(cgen.finish());
- _context->setBackends({"cpu"});
- _context->expectFailModelLoad();
-
- SUCCEED();
-}
-
-INSTANTIATE_TEST_CASE_P(GenModelTest, WhileWrongSubgraphIndex,
- ::testing::Values(std::make_pair(99, 2), std::make_pair(-1, 2),
- std::make_pair(1, 99), std::make_pair(1, -99),
- std::make_pair(-99, 99)));