diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/nnapi/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/nnfw_api/src/CircleGen.cc | 28 | ||||
-rw-r--r-- | tests/nnfw_api/src/CircleGen.h | 4 | ||||
-rw-r--r-- | tests/nnfw_api/src/GenModelTest.h | 23 | ||||
-rw-r--r-- | tests/nnfw_api/src/GenModelTests.test.cc (renamed from tests/nnfw_api/src/GenModelTests.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/ModelTestDynamicTensor.test.cc (renamed from tests/nnfw_api/src/ModelTestDynamicTensor.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/ModelTestInputReshaping.test.cc (renamed from tests/nnfw_api/src/ModelTestInputReshaping.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/RegressionTests.test.cc (renamed from tests/nnfw_api/src/RegressionTests.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/ValidationTestAddModelLoaded.test.cc (renamed from tests/nnfw_api/src/ValidationTestAddModelLoaded.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/ValidationTestAddSessionPrepared.test.cc (renamed from tests/nnfw_api/src/ValidationTestAddSessionPrepared.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/ValidationTestFourAddModelsSetInput.test.cc (renamed from tests/nnfw_api/src/ValidationTestFourAddModelsSetInput.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/ValidationTestMultipleSessions.test.cc (renamed from tests/nnfw_api/src/ValidationTestMultipleSessions.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/ValidationTestPipelineSession.test.cc (renamed from tests/nnfw_api/src/ValidationTestPipelineSession.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/ValidationTestSessionCreated.test.cc (renamed from tests/nnfw_api/src/ValidationTestSessionCreated.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/ValidationTestSingleSession.test.cc (renamed from tests/nnfw_api/src/ValidationTestSingleSession.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Add.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Add.cc) | 2 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/AddN.test.cc (renamed from tests/nnfw_api/src/one_op_tests/AddN.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/ArgMinMax.test.cc (renamed from tests/nnfw_api/src/one_op_tests/ArgMinMax.cc) | 2 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/AveragePool2D.test.cc (renamed from tests/nnfw_api/src/one_op_tests/AveragePool2D.cc) | 2 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/BatchToSpaceND.test.cc (renamed from tests/nnfw_api/src/one_op_tests/BatchToSpaceND.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Cast.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Cast.cc) | 28 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Concat.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Concat.cc) | 2 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Conv2D.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Conv2D.cc) | 30 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Cos.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Cos.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/DepthToSpace.test.cc (renamed from tests/nnfw_api/src/one_op_tests/DepthToSpace.cc) | 2 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/DepthwiseConv2D.test.cc (renamed from tests/nnfw_api/src/one_op_tests/DepthwiseConv2D.cc) | 49 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/DetectionPostProcess.test.cc (renamed from tests/nnfw_api/src/one_op_tests/DetectionPostProcess.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Elu.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Elu.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Equal.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Equal.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/ExpandDims.test.cc (renamed from tests/nnfw_api/src/one_op_tests/ExpandDims.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Fill.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Fill.cc) | 2 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Floor.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Floor.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/FloorDiv.test.cc (renamed from tests/nnfw_api/src/one_op_tests/FloorDiv.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/FullyConnected.test.cc (renamed from tests/nnfw_api/src/one_op_tests/FullyConnected.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Greater.test.cc | 144 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/GreaterEqual.test.cc | 145 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/If.test.cc (renamed from tests/nnfw_api/src/one_op_tests/If.cc) | 8 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/InstanceNorm.test.cc (renamed from tests/nnfw_api/src/one_op_tests/InstanceNorm.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/L2Normalization.test.cc (renamed from tests/nnfw_api/src/one_op_tests/L2Normalization.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/LeakyRelu.test.cc (renamed from tests/nnfw_api/src/one_op_tests/LeakyRelu.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Less.test.cc | 143 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/LessEqual.test.cc | 144 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/LogSoftmax.test.cc (renamed from tests/nnfw_api/src/one_op_tests/LogSoftmax.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Mean.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Mean.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Mul.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Mul.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Neg.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Neg.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/NotEqual.test.cc | 158 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/OneHot.test.cc (renamed from tests/nnfw_api/src/one_op_tests/OneHot.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Pad.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Pad.cc) | 2 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/PadV2.test.cc (renamed from tests/nnfw_api/src/one_op_tests/PadV2.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Quantize.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Quantize.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Rank.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Rank.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Reduce.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Reduce.cc) | 10 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Relu.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Relu.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Relu6.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Relu6.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/ResizeBilinear.test.cc (renamed from tests/nnfw_api/src/one_op_tests/ResizeBilinear.cc) | 2 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/ResizeNearestNeighbor.test.cc (renamed from tests/nnfw_api/src/one_op_tests/ResizeNearestNeighbor.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Reverse.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Reverse.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Select.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Select.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Shape.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Shape.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Slice.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Slice.cc) | 2 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Softmax.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Softmax.cc) | 2 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Split.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Split.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Sqrt.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Sqrt.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Square.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Square.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/StridedSlice.test.cc (renamed from tests/nnfw_api/src/one_op_tests/StridedSlice.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Sub.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Sub.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Tile.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Tile.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/Transpose.test.cc (renamed from tests/nnfw_api/src/one_op_tests/Transpose.cc) | 0 | ||||
-rw-r--r-- | tests/nnfw_api/src/one_op_tests/While.test.cc (renamed from tests/nnfw_api/src/one_op_tests/While.cc) | 14 | ||||
-rw-r--r-- | tests/scripts/command/nnpkg-test | 11 | ||||
-rw-r--r-- | tests/scripts/command/prepare-model | 12 | ||||
-rw-r--r-- | tests/tools/nnpackage_run/src/nnpackage_run.cc | 6 | ||||
-rw-r--r-- | tests/tools/nnpackage_run/src/rawformatter.cc | 26 | ||||
-rw-r--r-- | tests/tools/tflite_vanilla_run/CMakeLists.txt | 11 | ||||
-rw-r--r-- | tests/tools/tflite_vanilla_run/src/tflite_vanilla_run.cc | 7 |
76 files changed, 950 insertions, 76 deletions
diff --git a/tests/nnapi/CMakeLists.txt b/tests/nnapi/CMakeLists.txt index 67ac90f15..c1fa308a1 100644 --- a/tests/nnapi/CMakeLists.txt +++ b/tests/nnapi/CMakeLists.txt @@ -7,11 +7,6 @@ if (NOT BUILD_ONERT) return() endif(NOT BUILD_ONERT) -# GCC Compiler under 6.2 is not support this test build -if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.2) - return() -endif() - if (ANDROID_BOOST_ROOT) set(BOOST_ROOT ${ANDROID_BOOST_ROOT}) endif (ANDROID_BOOST_ROOT) diff --git a/tests/nnfw_api/src/CircleGen.cc b/tests/nnfw_api/src/CircleGen.cc index e4e4ba1af..4f1c7f9f5 100644 --- a/tests/nnfw_api/src/CircleGen.cc +++ b/tests/nnfw_api/src/CircleGen.cc @@ -269,6 +269,20 @@ uint32_t CircleGen::addOperatorFloorDiv(const OperatorParams ¶ms) circle::BuiltinOptions_NONE, 0); } +uint32_t CircleGen::addOperatorGreater(const OperatorParams ¶ms) +{ + auto options = circle::CreateLessOptions(_fbb).Union(); + return addOperatorWithOptions(params, circle::BuiltinOperator_GREATER, + circle::BuiltinOptions_GreaterOptions, options); +} + +uint32_t CircleGen::addOperatorGreaterEqual(const OperatorParams ¶ms) +{ + auto options = circle::CreateGreaterOptions(_fbb).Union(); + return addOperatorWithOptions(params, circle::BuiltinOperator_GREATER_EQUAL, + circle::BuiltinOptions_GreaterEqualOptions, options); +} + uint32_t CircleGen::addOperatorL2Normalization(const OperatorParams ¶ms) { auto options = circle::CreateL2NormOptions(_fbb).Union(); @@ -283,6 +297,13 @@ uint32_t CircleGen::addOperatorLess(const OperatorParams ¶ms) circle::BuiltinOptions_LessOptions, options); } +uint32_t CircleGen::addOperatorLessEqual(const OperatorParams ¶ms) +{ + auto options = circle::CreateLessOptions(_fbb).Union(); + return addOperatorWithOptions(params, circle::BuiltinOperator_LESS_EQUAL, + circle::BuiltinOptions_LessEqualOptions, options); +} + uint32_t CircleGen::addOperatorLeakyRelu(const OperatorParams ¶ms, float alpha) { auto options = circle::CreateLeakyReluOptions(_fbb, alpha).Union(); @@ -319,6 +340,13 @@ uint32_t CircleGen::addOperatorNeg(const OperatorParams ¶ms) circle::BuiltinOptions_NegOptions, options); } +uint32_t CircleGen::addOperatorNotEqual(const OperatorParams ¶ms) +{ + auto options = circle::CreateEqualOptions(_fbb).Union(); + return addOperatorWithOptions(params, circle::BuiltinOperator_NOT_EQUAL, + circle::BuiltinOptions_NotEqualOptions, options); +} + uint32_t CircleGen::addOperatorOneHot(const OperatorParams ¶ms, int32_t axis) { auto options = circle::CreateOneHotOptions(_fbb, axis).Union(); diff --git a/tests/nnfw_api/src/CircleGen.h b/tests/nnfw_api/src/CircleGen.h index 062a8d35a..d780eb1bb 100644 --- a/tests/nnfw_api/src/CircleGen.h +++ b/tests/nnfw_api/src/CircleGen.h @@ -174,16 +174,20 @@ public: uint32_t addOperatorFullyConnected(const OperatorParams ¶ms, circle::FullyConnectedOptionsWeightsFormat weights_format = circle::FullyConnectedOptionsWeightsFormat_DEFAULT); + uint32_t addOperatorGreater(const OperatorParams ¶ms); + uint32_t addOperatorGreaterEqual(const OperatorParams ¶ms); uint32_t addOperatorIf(const OperatorParams ¶ms, uint32_t then_subg, uint32_t else_subg); uint32_t addOperatorInstanceNorm(const OperatorParams ¶ms, float epsilon, circle::ActivationFunctionType actfn); uint32_t addOperatorL2Normalization(const OperatorParams ¶ms); uint32_t addOperatorLeakyRelu(const OperatorParams ¶ms, float alpha); uint32_t addOperatorLess(const OperatorParams ¶ms); + uint32_t addOperatorLessEqual(const OperatorParams ¶ms); uint32_t addOperatorLogSoftmax(const OperatorParams ¶ms); uint32_t addOperatorMul(const OperatorParams ¶ms, circle::ActivationFunctionType actfn); uint32_t addOperatorMean(const OperatorParams ¶ms, bool keep_dims); uint32_t addOperatorNeg(const OperatorParams ¶ms); + uint32_t addOperatorNotEqual(const OperatorParams ¶ms); uint32_t addOperatorOneHot(const OperatorParams ¶ms, int32_t axis); uint32_t addOperatorPad(const OperatorParams ¶ms); uint32_t addOperatorPadV2(const OperatorParams ¶ms); diff --git a/tests/nnfw_api/src/GenModelTest.h b/tests/nnfw_api/src/GenModelTest.h index eee50d112..90b7cfcad 100644 --- a/tests/nnfw_api/src/GenModelTest.h +++ b/tests/nnfw_api/src/GenModelTest.h @@ -398,7 +398,9 @@ protected: // Check output tensor values auto &ref_output = ref_outputs[i]; auto &output = _so.outputs[i]; - ASSERT_EQ(output.size(), ref_output.size()); + auto expected_tensor_size = ref_output.size(); + auto actual_tensor_size = output.size(); + ASSERT_EQ(expected_tensor_size, actual_tensor_size) << "Output #" << i; switch (ti.dtype) { @@ -419,9 +421,10 @@ protected: // 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; + float expected = reinterpret_cast<const float *>(ref_output.data())[e]; + float actual = reinterpret_cast<const float *>(output.data())[e]; + EXPECT_NEAR(expected, actual, 0.001) + << "Output #" << i << ", Element Index : " << e; } break; case NNFW_TYPE_TENSOR_INT64: @@ -445,9 +448,9 @@ private: { 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; + T expected = reinterpret_cast<const T *>(ref_buf.data())[e]; + T actual = reinterpret_cast<const T *>(act_buf.data())[e]; + EXPECT_EQ(expected, actual) << "Output #" << index << ", Element Index : " << e; } } @@ -457,10 +460,10 @@ private: 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); + bool expected = (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; + bool actual = (act_raw != 0 ? true : false); + EXPECT_EQ(expected, actual) << "Output #" << index << ", Element Index : " << e; } } diff --git a/tests/nnfw_api/src/GenModelTests.cc b/tests/nnfw_api/src/GenModelTests.test.cc index 53a3571db..53a3571db 100644 --- a/tests/nnfw_api/src/GenModelTests.cc +++ b/tests/nnfw_api/src/GenModelTests.test.cc diff --git a/tests/nnfw_api/src/ModelTestDynamicTensor.cc b/tests/nnfw_api/src/ModelTestDynamicTensor.test.cc index 1ed8f9581..1ed8f9581 100644 --- a/tests/nnfw_api/src/ModelTestDynamicTensor.cc +++ b/tests/nnfw_api/src/ModelTestDynamicTensor.test.cc diff --git a/tests/nnfw_api/src/ModelTestInputReshaping.cc b/tests/nnfw_api/src/ModelTestInputReshaping.test.cc index f5ce3e062..f5ce3e062 100644 --- a/tests/nnfw_api/src/ModelTestInputReshaping.cc +++ b/tests/nnfw_api/src/ModelTestInputReshaping.test.cc diff --git a/tests/nnfw_api/src/RegressionTests.cc b/tests/nnfw_api/src/RegressionTests.test.cc index de233390d..de233390d 100644 --- a/tests/nnfw_api/src/RegressionTests.cc +++ b/tests/nnfw_api/src/RegressionTests.test.cc diff --git a/tests/nnfw_api/src/ValidationTestAddModelLoaded.cc b/tests/nnfw_api/src/ValidationTestAddModelLoaded.test.cc index 4c482369f..4c482369f 100644 --- a/tests/nnfw_api/src/ValidationTestAddModelLoaded.cc +++ b/tests/nnfw_api/src/ValidationTestAddModelLoaded.test.cc diff --git a/tests/nnfw_api/src/ValidationTestAddSessionPrepared.cc b/tests/nnfw_api/src/ValidationTestAddSessionPrepared.test.cc index d668a1cb0..d668a1cb0 100644 --- a/tests/nnfw_api/src/ValidationTestAddSessionPrepared.cc +++ b/tests/nnfw_api/src/ValidationTestAddSessionPrepared.test.cc diff --git a/tests/nnfw_api/src/ValidationTestFourAddModelsSetInput.cc b/tests/nnfw_api/src/ValidationTestFourAddModelsSetInput.test.cc index e09402b01..e09402b01 100644 --- a/tests/nnfw_api/src/ValidationTestFourAddModelsSetInput.cc +++ b/tests/nnfw_api/src/ValidationTestFourAddModelsSetInput.test.cc diff --git a/tests/nnfw_api/src/ValidationTestMultipleSessions.cc b/tests/nnfw_api/src/ValidationTestMultipleSessions.test.cc index ef00dc6bd..ef00dc6bd 100644 --- a/tests/nnfw_api/src/ValidationTestMultipleSessions.cc +++ b/tests/nnfw_api/src/ValidationTestMultipleSessions.test.cc diff --git a/tests/nnfw_api/src/ValidationTestPipelineSession.cc b/tests/nnfw_api/src/ValidationTestPipelineSession.test.cc index 1d92095ed..1d92095ed 100644 --- a/tests/nnfw_api/src/ValidationTestPipelineSession.cc +++ b/tests/nnfw_api/src/ValidationTestPipelineSession.test.cc diff --git a/tests/nnfw_api/src/ValidationTestSessionCreated.cc b/tests/nnfw_api/src/ValidationTestSessionCreated.test.cc index cb0791933..cb0791933 100644 --- a/tests/nnfw_api/src/ValidationTestSessionCreated.cc +++ b/tests/nnfw_api/src/ValidationTestSessionCreated.test.cc diff --git a/tests/nnfw_api/src/ValidationTestSingleSession.cc b/tests/nnfw_api/src/ValidationTestSingleSession.test.cc index 852d5cd21..852d5cd21 100644 --- a/tests/nnfw_api/src/ValidationTestSingleSession.cc +++ b/tests/nnfw_api/src/ValidationTestSingleSession.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Add.cc b/tests/nnfw_api/src/one_op_tests/Add.test.cc index c21022972..9fc0e86b6 100644 --- a/tests/nnfw_api/src/one_op_tests/Add.cc +++ b/tests/nnfw_api/src/one_op_tests/Add.test.cc @@ -283,7 +283,7 @@ TEST_F(GenModelTest, neg_OneOp_Add_VarToVarSize0_InvalidShape) SUCCEED(); } -TEST_F(GenModelTest, net_OneOp_Add_VarToVarInt16) +TEST_F(GenModelTest, neg_OneOp_Add_VarToVarInt16) { CircleGen cgen; int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT16}, 1., 2); diff --git a/tests/nnfw_api/src/one_op_tests/AddN.cc b/tests/nnfw_api/src/one_op_tests/AddN.test.cc index 73fa82168..73fa82168 100644 --- a/tests/nnfw_api/src/one_op_tests/AddN.cc +++ b/tests/nnfw_api/src/one_op_tests/AddN.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/ArgMinMax.cc b/tests/nnfw_api/src/one_op_tests/ArgMinMax.test.cc index dda098698..1321552db 100644 --- a/tests/nnfw_api/src/one_op_tests/ArgMinMax.cc +++ b/tests/nnfw_api/src/one_op_tests/ArgMinMax.test.cc @@ -37,7 +37,7 @@ class ArgMinMaxVariation : public GenModelTest, // Output shape: {1, 2, 1} // Output type: Int32 // Test with different input type and value -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, ArgMinMaxVariation, ::testing::Values( // ArgMax, float input diff --git a/tests/nnfw_api/src/one_op_tests/AveragePool2D.cc b/tests/nnfw_api/src/one_op_tests/AveragePool2D.test.cc index 15ddac210..8276ca4c1 100644 --- a/tests/nnfw_api/src/one_op_tests/AveragePool2D.cc +++ b/tests/nnfw_api/src/one_op_tests/AveragePool2D.test.cc @@ -43,7 +43,7 @@ class AveragePool2DVariation : public GenModelTest, }; // Test with different input type and value -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, AveragePool2DVariation, ::testing::Values( // float data diff --git a/tests/nnfw_api/src/one_op_tests/BatchToSpaceND.cc b/tests/nnfw_api/src/one_op_tests/BatchToSpaceND.test.cc index 3f4554302..3f4554302 100644 --- a/tests/nnfw_api/src/one_op_tests/BatchToSpaceND.cc +++ b/tests/nnfw_api/src/one_op_tests/BatchToSpaceND.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Cast.cc b/tests/nnfw_api/src/one_op_tests/Cast.test.cc index 928df2d24..b4cfa6f8f 100644 --- a/tests/nnfw_api/src/one_op_tests/Cast.cc +++ b/tests/nnfw_api/src/one_op_tests/Cast.test.cc @@ -89,6 +89,34 @@ TEST_F(GenModelTest, OneOp_Cast_BoolToInt32) SUCCEED(); } +TEST_F(GenModelTest, OneOp_Cast_Uint8ToFloat32) +{ + CircleGen cgen = genSimpleCastModel(circle::TensorType_UINT8, circle::TensorType_FLOAT32); + + _context = std::make_unique<GenModelTestContext>(cgen.finish()); + // clang-format off + _context->addTestCase( + TestCaseData{}.addInput<uint8_t>({0, 100, 200, 255}) + .addOutput<float>({0., 100., 200., 255.})); + // clang-format on + _context->setBackends({"acl_cl", "acl_neon", "cpu"}); + + SUCCEED(); +} + +TEST_F(GenModelTest, OneOp_Cast_Int64ToFloat32) +{ + CircleGen cgen = genSimpleCastModel(circle::TensorType_INT64, circle::TensorType_FLOAT32); + + _context = std::make_unique<GenModelTestContext>(cgen.finish()); + _context->addTestCase(TestCaseData{} + .addInput<int64_t>({-12345, 3, 100, 2147483648}) + .addOutput<float>({-12345., 3., 100., 2147483648.})); + _context->setBackends({"cpu"}); + + SUCCEED(); +} + TEST_F(GenModelTest, OneOp_Cast_AfterEqual) { CircleGen cgen; diff --git a/tests/nnfw_api/src/one_op_tests/Concat.cc b/tests/nnfw_api/src/one_op_tests/Concat.test.cc index f4397ba66..4f8360353 100644 --- a/tests/nnfw_api/src/one_op_tests/Concat.cc +++ b/tests/nnfw_api/src/one_op_tests/Concat.test.cc @@ -59,7 +59,7 @@ class ConcatVariation : public GenModelTest, // Input shape: {2, 3} / {2, 3} // Output shape: {4, 3} -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, ConcatVariation, ::testing::Values( // Float diff --git a/tests/nnfw_api/src/one_op_tests/Conv2D.cc b/tests/nnfw_api/src/one_op_tests/Conv2D.test.cc index 4f58e3d53..dccf2e5b8 100644 --- a/tests/nnfw_api/src/one_op_tests/Conv2D.cc +++ b/tests/nnfw_api/src/one_op_tests/Conv2D.test.cc @@ -136,6 +136,36 @@ TEST_F(GenModelTest, OneOp_Conv2D_I8_PerChannel) SUCCEED(); } +TEST_F(GenModelTest, OneOp_Conv2D_U8_PerChannel) +{ + CircleGen cgen; + // weight + std::vector<uint8_t> weight_data{2, 6, 2, 1, 2, 3, 2, 3, 4}; + uint32_t weight_buf = cgen.addBuffer(weight_data); + std::vector<float> weight_scales = {.5, 1, 2}; + std::vector<int64_t> weight_zeropoints = {2, 0, 1}; + int weight = cgen.addTensor({{3, 1, 1, 3}, circle::TensorType::TensorType_UINT8, weight_buf}, + weight_scales, weight_zeropoints); + // bias + std::vector<int32_t> bias_data{4, -8, -4}; + uint32_t bias_buf = cgen.addBuffer(bias_data); + int bias = cgen.addTensor({{1, 1, 1, 3}, circle::TensorType::TensorType_INT32, bias_buf}, 1., 0); + + // in and out + int in = cgen.addTensor({{1, 1, 1, 3}, circle::TensorType::TensorType_UINT8}, 2., 1); + int out = cgen.addTensor({{1, 1, 1, 3}, circle::TensorType::TensorType_UINT8}, 4., 2); + + cgen.addOperatorConv2D({{in, weight, bias}, {out}}, circle::Padding_VALID, 1, 1, + circle::ActivationFunctionType_NONE); + cgen.setInputsAndOutputs({in}, {out}); + + _context = std::make_unique<GenModelTestContext>(cgen.finish()); + _context->addTestCase(uniformTCD<uint8_t>({{5, 3, 7}}, {{5, 11, 24}})); + _context->setBackends({"cpu"}); + + SUCCEED(); +} + TEST_F(GenModelTest, neg_OneOp_Conv2D_Type) { CircleGen cgen; diff --git a/tests/nnfw_api/src/one_op_tests/Cos.cc b/tests/nnfw_api/src/one_op_tests/Cos.test.cc index 03944746a..03944746a 100644 --- a/tests/nnfw_api/src/one_op_tests/Cos.cc +++ b/tests/nnfw_api/src/one_op_tests/Cos.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/DepthToSpace.cc b/tests/nnfw_api/src/one_op_tests/DepthToSpace.test.cc index a4fe88493..ad2272996 100644 --- a/tests/nnfw_api/src/one_op_tests/DepthToSpace.cc +++ b/tests/nnfw_api/src/one_op_tests/DepthToSpace.test.cc @@ -32,7 +32,7 @@ class DepthToSpaceVariation : public GenModelTest, // Input shape: {1, 1, 2, 4} // Block size: 2 // Output shape: {1, 2, 4, 1} -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, DepthToSpaceVariation, ::testing::Values( // Float diff --git a/tests/nnfw_api/src/one_op_tests/DepthwiseConv2D.cc b/tests/nnfw_api/src/one_op_tests/DepthwiseConv2D.test.cc index a0bdbf9e6..f82d988d5 100644 --- a/tests/nnfw_api/src/one_op_tests/DepthwiseConv2D.cc +++ b/tests/nnfw_api/src/one_op_tests/DepthwiseConv2D.test.cc @@ -158,6 +158,51 @@ TEST_F(GenModelTest, OneOp_DepthwiseConv2D_Dilation_N_Stride) SUCCEED(); } +TEST_F(GenModelTest, OneOp_DepthwiseConv2D_U8_PerChannel) +{ + CircleGen cgen; + // weight + // clang-format off + std::vector<uint8_t> weight_data{2, 1, 2, + 6, 2, 3, + 2, 3, 4, + 4, 4, 5}; + // clang-format on + uint32_t weight_buf = cgen.addBuffer(weight_data); + std::vector<float> weight_scales = {.5, 1, 2}; + std::vector<int64_t> weight_zeropoints = {2, 0, 1}; + int weight = cgen.addTensor({{1, 2, 2, 3}, circle::TensorType::TensorType_UINT8, weight_buf}, + weight_scales, weight_zeropoints); + // bias + std::vector<int32_t> bias_data{4, -8, -4}; + uint32_t bias_buf = cgen.addBuffer(bias_data); + int bias = cgen.addTensor({{1, 1, 1, 3}, circle::TensorType::TensorType_INT32, bias_buf}, 1., 0); + + // in and out + int in = cgen.addTensor({{1, 2, 2, 3}, circle::TensorType::TensorType_UINT8}, 2., 1); + int out = cgen.addTensor({{1, 1, 1, 3}, circle::TensorType::TensorType_UINT8}, 4., 2); + + cgen.addOperatorDepthwiseConv2D({{in, weight, bias}, {out}}, circle::Padding_VALID, 1, 1, 1, + circle::ActivationFunctionType_NONE); + cgen.setInputsAndOutputs({in}, {out}); + + _context = std::make_unique<GenModelTestContext>(cgen.finish()); + // clang-format off + _context->addTestCase(uniformTCD<uint8_t>({{5, 5, 5, // NHWC + 3, 3, 3, + 7, 7, 7, + 9, 9, 9} + }, + {{9, + 27, + 56} + })); + // clang-format on + _context->setBackends({"cpu"}); + + SUCCEED(); +} + TEST_F(GenModelTest, neg_OneOp_DepthwiseConv2D_Stride) { CircleGen cgen; @@ -259,7 +304,7 @@ using DepthwiseConv2DQuantTestU8 = DepthwiseConv2DQuantTest<uint8_t>; // Test with different InputDepth and DepthMultiplier. The values are intended to test optimized CPU // kernels. -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, DepthwiseConv2DQuantTestU8, ::testing::Values( // Stride == 1 @@ -342,7 +387,7 @@ using DepthwiseConv2DQuantTestI8 = DepthwiseConv2DQuantTest<int8_t>; // Test with different InputDepth and DepthMultiplier. The values are intended to test optimized CPU // kernels. -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, DepthwiseConv2DQuantTestI8, ::testing::Values( // Stride == 1 diff --git a/tests/nnfw_api/src/one_op_tests/DetectionPostProcess.cc b/tests/nnfw_api/src/one_op_tests/DetectionPostProcess.test.cc index 188638bbb..188638bbb 100644 --- a/tests/nnfw_api/src/one_op_tests/DetectionPostProcess.cc +++ b/tests/nnfw_api/src/one_op_tests/DetectionPostProcess.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Elu.cc b/tests/nnfw_api/src/one_op_tests/Elu.test.cc index a037070b2..a037070b2 100644 --- a/tests/nnfw_api/src/one_op_tests/Elu.cc +++ b/tests/nnfw_api/src/one_op_tests/Elu.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Equal.cc b/tests/nnfw_api/src/one_op_tests/Equal.test.cc index da890978e..da890978e 100644 --- a/tests/nnfw_api/src/one_op_tests/Equal.cc +++ b/tests/nnfw_api/src/one_op_tests/Equal.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/ExpandDims.cc b/tests/nnfw_api/src/one_op_tests/ExpandDims.test.cc index 280cf7344..280cf7344 100644 --- a/tests/nnfw_api/src/one_op_tests/ExpandDims.cc +++ b/tests/nnfw_api/src/one_op_tests/ExpandDims.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Fill.cc b/tests/nnfw_api/src/one_op_tests/Fill.test.cc index 4d5e4d8be..0d34056b3 100644 --- a/tests/nnfw_api/src/one_op_tests/Fill.cc +++ b/tests/nnfw_api/src/one_op_tests/Fill.test.cc @@ -56,7 +56,7 @@ const int64_t test_int64 = 1052; const float test_float = 5.2; // Test with different value type -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, FillVariation, ::testing::Values( // float value diff --git a/tests/nnfw_api/src/one_op_tests/Floor.cc b/tests/nnfw_api/src/one_op_tests/Floor.test.cc index dcb402027..dcb402027 100644 --- a/tests/nnfw_api/src/one_op_tests/Floor.cc +++ b/tests/nnfw_api/src/one_op_tests/Floor.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/FloorDiv.cc b/tests/nnfw_api/src/one_op_tests/FloorDiv.test.cc index edbca8504..edbca8504 100644 --- a/tests/nnfw_api/src/one_op_tests/FloorDiv.cc +++ b/tests/nnfw_api/src/one_op_tests/FloorDiv.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/FullyConnected.cc b/tests/nnfw_api/src/one_op_tests/FullyConnected.test.cc index 791787f9b..791787f9b 100644 --- a/tests/nnfw_api/src/one_op_tests/FullyConnected.cc +++ b/tests/nnfw_api/src/one_op_tests/FullyConnected.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Greater.test.cc b/tests/nnfw_api/src/one_op_tests/Greater.test.cc new file mode 100644 index 000000000..b63075c0e --- /dev/null +++ b/tests/nnfw_api/src/one_op_tests/Greater.test.cc @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2022 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" + +struct GreaterVariationParam +{ + TestCaseData tcd; + circle::TensorType input_type = circle::TensorType::TensorType_FLOAT32; + const std::vector<std::string> backends = {"acl_cl", "acl_neon", "cpu"}; +}; + +class GreaterVariation : public GenModelTest, + public ::testing::WithParamInterface<GreaterVariationParam> +{ +}; + +// Input shape: +// Base: {1, 2, 2, 1} +// Brodcast: {1} on of two input +// Output shape: {1, 2, 2, 1} +// Input type: Non-quantization type +// Output type: BOOL +// Test with different input type and value +INSTANTIATE_TEST_SUITE_P(GenModelTest, GreaterVariation, + ::testing::Values( + // Float type + GreaterVariationParam{TestCaseData{} + .addInput<float>({0.1, 0.3, 0.2, 0.7}) + .addInput<float>({0.1, 0.2, 0.3, 0.4}) + .addOutput<bool>({false, true, false, true})}, + // Float type - broadcast + GreaterVariationParam{TestCaseData{} + .addInput<float>({0.1, 0.3, 0.2, 0.7}) + .addInput<float>({0.3}) + .addOutput<bool>({false, false, false, true})}, + // Int32 type + GreaterVariationParam{TestCaseData{} + .addInput<int32_t>({1, 3, 2, 7}) + .addInput<int32_t>({1, 2, 3, 4}) + .addOutput<bool>({false, true, false, true}), + circle::TensorType::TensorType_INT32}, + // Int32 type - broadcast + GreaterVariationParam{TestCaseData{} + .addInput<int32_t>({1, 3, 2, 7}) + .addInput<int32_t>({5}) + .addOutput<bool>({false, false, false, true}), + circle::TensorType::TensorType_INT32}, + // Int64 type + // NYI: acl backend + GreaterVariationParam{TestCaseData{} + .addInput<int64_t>({1, 3, -2, 7}) + .addInput<int64_t>({1, 2, 3, 4}) + .addOutput<bool>({false, true, false, true}), + circle::TensorType::TensorType_INT64, + {"cpu"}}, + // Int64 type - broadcast + // NYI: acl backend + GreaterVariationParam{TestCaseData{} + .addInput<int64_t>({1, 3, -2, 7}) + .addInput<int64_t>({1}) + .addOutput<bool>({false, true, false, true}), + circle::TensorType::TensorType_INT64, + {"cpu"}})); + +TEST_P(GreaterVariation, Test) +{ + auto ¶m = GetParam(); + + auto lhs_data = param.tcd.inputs.at(0); + auto rhs_data = param.tcd.inputs.at(1); + + bool broadcast_lhs = false; + bool broadcast_rhs = false; + if (lhs_data.size() != rhs_data.size()) + { + if (lhs_data.size() < rhs_data.size()) + broadcast_lhs = true; + else + broadcast_rhs = true; + } + + CircleGen cgen; + const auto output_type = circle::TensorType::TensorType_BOOL; + + int lhs = broadcast_lhs ? cgen.addTensor({{1}, param.input_type}) + : cgen.addTensor({{1, 2, 2, 1}, param.input_type}); + int rhs = broadcast_rhs ? cgen.addTensor({{1}, param.input_type}) + : cgen.addTensor({{1, 2, 2, 1}, param.input_type}); + int out = cgen.addTensor({{1, 2, 2, 1}, output_type}); + cgen.addOperatorGreater({{lhs, rhs}, {out}}); + cgen.setInputsAndOutputs({lhs, rhs}, {out}); + + _context = std::make_unique<GenModelTestContext>(cgen.finish()); + _context->addTestCase(param.tcd); + _context->setBackends(param.backends); + + SUCCEED(); +} + +TEST_F(GenModelTest, neg_OneOp_Greater_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.addOperatorGreater({{lhs, rhs}, {out}}); + 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_Greater_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.addOperatorGreater({{lhs, rhs}, {out}}); + cgen.setInputsAndOutputs({lhs, rhs}, {out}); + + _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/GreaterEqual.test.cc b/tests/nnfw_api/src/one_op_tests/GreaterEqual.test.cc new file mode 100644 index 000000000..f824030e0 --- /dev/null +++ b/tests/nnfw_api/src/one_op_tests/GreaterEqual.test.cc @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2022 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" + +struct GreaterEqualVariationParam +{ + TestCaseData tcd; + circle::TensorType input_type = circle::TensorType::TensorType_FLOAT32; + const std::vector<std::string> backends = {"acl_cl", "acl_neon", "cpu"}; +}; + +class GreaterEqualVariation : public GenModelTest, + public ::testing::WithParamInterface<GreaterEqualVariationParam> +{ +}; + +// Input shape: +// Base: {1, 2, 2, 1} +// Brodcast: {1} on of two input +// Output shape: {1, 2, 2, 1} +// Input type: Non-quantization type +// Output type: BOOL +// Test with different input type and value +INSTANTIATE_TEST_SUITE_P( + GenModelTest, GreaterEqualVariation, + ::testing::Values( + // Float type + GreaterEqualVariationParam{TestCaseData{} + .addInput<float>({0.1, 0.3, 0.2, 0.7}) + .addInput<float>({0.1, 0.2, 0.3, 0.4}) + .addOutput<bool>({true, true, false, true})}, + // Float type - broadcast + GreaterEqualVariationParam{TestCaseData{} + .addInput<float>({0.1, 0.3, 0.2, 0.7}) + .addInput<float>({0.3}) + .addOutput<bool>({false, true, false, true})}, + // Int32 type + GreaterEqualVariationParam{TestCaseData{} + .addInput<int32_t>({1, 3, 2, 7}) + .addInput<int32_t>({1, 2, 3, 4}) + .addOutput<bool>({true, true, false, true}), + circle::TensorType::TensorType_INT32}, + // Int32 type - broadcast + GreaterEqualVariationParam{TestCaseData{} + .addInput<int32_t>({1, 3, 2, 7}) + .addInput<int32_t>({5}) + .addOutput<bool>({false, false, false, true}), + circle::TensorType::TensorType_INT32}, + // Int64 type + // NYI: acl backend + GreaterEqualVariationParam{TestCaseData{} + .addInput<int64_t>({1, 3, -2, 7}) + .addInput<int64_t>({1, 2, 3, 4}) + .addOutput<bool>({true, true, false, true}), + circle::TensorType::TensorType_INT64, + {"cpu"}}, + // Int64 type - broadcast + // NYI: acl backend + GreaterEqualVariationParam{TestCaseData{} + .addInput<int64_t>({1, 3, -2, 7}) + .addInput<int64_t>({1}) + .addOutput<bool>({true, true, false, true}), + circle::TensorType::TensorType_INT64, + {"cpu"}})); + +TEST_P(GreaterEqualVariation, Test) +{ + auto ¶m = GetParam(); + + auto lhs_data = param.tcd.inputs.at(0); + auto rhs_data = param.tcd.inputs.at(1); + + bool broadcast_lhs = false; + bool broadcast_rhs = false; + if (lhs_data.size() != rhs_data.size()) + { + if (lhs_data.size() < rhs_data.size()) + broadcast_lhs = true; + else + broadcast_rhs = true; + } + + CircleGen cgen; + const auto output_type = circle::TensorType::TensorType_BOOL; + + int lhs = broadcast_lhs ? cgen.addTensor({{1}, param.input_type}) + : cgen.addTensor({{1, 2, 2, 1}, param.input_type}); + int rhs = broadcast_rhs ? cgen.addTensor({{1}, param.input_type}) + : cgen.addTensor({{1, 2, 2, 1}, param.input_type}); + int out = cgen.addTensor({{1, 2, 2, 1}, output_type}); + cgen.addOperatorGreaterEqual({{lhs, rhs}, {out}}); + cgen.setInputsAndOutputs({lhs, rhs}, {out}); + + _context = std::make_unique<GenModelTestContext>(cgen.finish()); + _context->addTestCase(param.tcd); + _context->setBackends(param.backends); + + SUCCEED(); +} + +TEST_F(GenModelTest, neg_OneOp_GreaterEqual_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.addOperatorGreaterEqual({{lhs, rhs}, {out}}); + 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_GreaterEqual_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.addOperatorGreaterEqual({{lhs, rhs}, {out}}); + cgen.setInputsAndOutputs({lhs, rhs}, {out}); + + _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/If.cc b/tests/nnfw_api/src/one_op_tests/If.test.cc index 4ec294223..543d87980 100644 --- a/tests/nnfw_api/src/one_op_tests/If.cc +++ b/tests/nnfw_api/src/one_op_tests/If.test.cc @@ -126,7 +126,7 @@ TEST_P(IfWrongSubgraphIndex, neg_Test) 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))); +INSTANTIATE_TEST_SUITE_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.test.cc index 6569ced21..6569ced21 100644 --- a/tests/nnfw_api/src/one_op_tests/InstanceNorm.cc +++ b/tests/nnfw_api/src/one_op_tests/InstanceNorm.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/L2Normalization.cc b/tests/nnfw_api/src/one_op_tests/L2Normalization.test.cc index f825fec5c..f825fec5c 100644 --- a/tests/nnfw_api/src/one_op_tests/L2Normalization.cc +++ b/tests/nnfw_api/src/one_op_tests/L2Normalization.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/LeakyRelu.cc b/tests/nnfw_api/src/one_op_tests/LeakyRelu.test.cc index cb3af4ee2..cb3af4ee2 100644 --- a/tests/nnfw_api/src/one_op_tests/LeakyRelu.cc +++ b/tests/nnfw_api/src/one_op_tests/LeakyRelu.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Less.test.cc b/tests/nnfw_api/src/one_op_tests/Less.test.cc new file mode 100644 index 000000000..6f76465ae --- /dev/null +++ b/tests/nnfw_api/src/one_op_tests/Less.test.cc @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2022 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" + +struct LessVariationParam +{ + TestCaseData tcd; + circle::TensorType input_type = circle::TensorType::TensorType_FLOAT32; + const std::vector<std::string> backends = {"acl_cl", "acl_neon", "cpu"}; +}; + +class LessVariation : public GenModelTest, public ::testing::WithParamInterface<LessVariationParam> +{ +}; + +// Input shape: +// Base: {1, 2, 2, 1} +// Brodcast: {1} on of two input +// Output shape: {1, 2, 2, 1} +// Input type: Non-quantization type +// Output type: BOOL +// Test with different input type and value +INSTANTIATE_TEST_SUITE_P(GenModelTest, LessVariation, + ::testing::Values( + // Float type + LessVariationParam{TestCaseData{} + .addInput<float>({0.1, 0.3, 0.2, 0.7}) + .addInput<float>({0.1, 0.2, 0.3, 0.4}) + .addOutput<bool>({false, false, true, false})}, + // Float type - broadcast + LessVariationParam{TestCaseData{} + .addInput<float>({0.1, 0.3, 0.2, 0.7}) + .addInput<float>({0.3}) + .addOutput<bool>({true, false, true, false})}, + // Int32 type + LessVariationParam{TestCaseData{} + .addInput<int32_t>({1, 3, 2, 7}) + .addInput<int32_t>({1, 2, 3, 4}) + .addOutput<bool>({false, false, true, false}), + circle::TensorType::TensorType_INT32}, + // Int32 type - broadcast + LessVariationParam{TestCaseData{} + .addInput<int32_t>({1, 3, 2, 7}) + .addInput<int32_t>({5}) + .addOutput<bool>({true, true, true, false}), + circle::TensorType::TensorType_INT32}, + // Int64 type + // NYI: acl backend + LessVariationParam{TestCaseData{} + .addInput<int64_t>({1, 3, -2, 7}) + .addInput<int64_t>({1, 2, 3, 4}) + .addOutput<bool>({false, false, true, false}), + circle::TensorType::TensorType_INT64, + {"cpu"}}, + // Int64 type - broadcast + // NYI: acl backend + LessVariationParam{TestCaseData{} + .addInput<int64_t>({1, 3, -2, 7}) + .addInput<int64_t>({1}) + .addOutput<bool>({false, false, true, false}), + circle::TensorType::TensorType_INT64, + {"cpu"}})); + +TEST_P(LessVariation, Test) +{ + auto ¶m = GetParam(); + + auto lhs_data = param.tcd.inputs.at(0); + auto rhs_data = param.tcd.inputs.at(1); + + bool broadcast_lhs = false; + bool broadcast_rhs = false; + if (lhs_data.size() != rhs_data.size()) + { + if (lhs_data.size() < rhs_data.size()) + broadcast_lhs = true; + else + broadcast_rhs = true; + } + + CircleGen cgen; + const auto output_type = circle::TensorType::TensorType_BOOL; + + int lhs = broadcast_lhs ? cgen.addTensor({{1}, param.input_type}) + : cgen.addTensor({{1, 2, 2, 1}, param.input_type}); + int rhs = broadcast_rhs ? cgen.addTensor({{1}, param.input_type}) + : cgen.addTensor({{1, 2, 2, 1}, param.input_type}); + int out = cgen.addTensor({{1, 2, 2, 1}, output_type}); + cgen.addOperatorLess({{lhs, rhs}, {out}}); + cgen.setInputsAndOutputs({lhs, rhs}, {out}); + + _context = std::make_unique<GenModelTestContext>(cgen.finish()); + _context->addTestCase(param.tcd); + _context->setBackends(param.backends); + + SUCCEED(); +} + +TEST_F(GenModelTest, neg_OneOp_Less_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.addOperatorLess({{lhs, rhs}, {out}}); + 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_Less_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.addOperatorLess({{lhs, rhs}, {out}}); + cgen.setInputsAndOutputs({lhs, rhs}, {out}); + + _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/LessEqual.test.cc b/tests/nnfw_api/src/one_op_tests/LessEqual.test.cc new file mode 100644 index 000000000..e0e6d6698 --- /dev/null +++ b/tests/nnfw_api/src/one_op_tests/LessEqual.test.cc @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2022 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" + +struct LessEqualVariationParam +{ + TestCaseData tcd; + circle::TensorType input_type = circle::TensorType::TensorType_FLOAT32; + const std::vector<std::string> backends = {"acl_cl", "acl_neon", "cpu"}; +}; + +class LessEqualVariation : public GenModelTest, + public ::testing::WithParamInterface<LessEqualVariationParam> +{ +}; + +// Input shape: +// Base: {1, 2, 2, 1} +// Brodcast: {1} on of two input +// Output shape: {1, 2, 2, 1} +// Input type: Non-quantization type +// Output type: BOOL +// Test with different input type and value +INSTANTIATE_TEST_SUITE_P(GenModelTest, LessEqualVariation, + ::testing::Values( + // Float type + LessEqualVariationParam{TestCaseData{} + .addInput<float>({0.1, 0.3, 0.2, 0.7}) + .addInput<float>({0.1, 0.2, 0.3, 0.4}) + .addOutput<bool>({true, false, true, false})}, + // Float type - broadcast + LessEqualVariationParam{TestCaseData{} + .addInput<float>({0.1, 0.3, 0.2, 0.7}) + .addInput<float>({0.3}) + .addOutput<bool>({true, true, true, false})}, + // Int32 type + LessEqualVariationParam{TestCaseData{} + .addInput<int32_t>({1, 3, 2, 7}) + .addInput<int32_t>({1, 2, 3, 4}) + .addOutput<bool>({true, false, true, false}), + circle::TensorType::TensorType_INT32}, + // Int32 type - broadcast + LessEqualVariationParam{TestCaseData{} + .addInput<int32_t>({1, 3, 2, 7}) + .addInput<int32_t>({5}) + .addOutput<bool>({true, true, true, false}), + circle::TensorType::TensorType_INT32}, + // Int64 type + // NYI: acl backend + LessEqualVariationParam{TestCaseData{} + .addInput<int64_t>({1, 3, -2, 7}) + .addInput<int64_t>({1, 2, 3, 4}) + .addOutput<bool>({true, false, true, false}), + circle::TensorType::TensorType_INT64, + {"cpu"}}, + // Int64 type - broadcast + // NYI: acl backend + LessEqualVariationParam{TestCaseData{} + .addInput<int64_t>({1, 3, -2, 7}) + .addInput<int64_t>({1}) + .addOutput<bool>({true, false, true, false}), + circle::TensorType::TensorType_INT64, + {"cpu"}})); + +TEST_P(LessEqualVariation, Test) +{ + auto ¶m = GetParam(); + + auto lhs_data = param.tcd.inputs.at(0); + auto rhs_data = param.tcd.inputs.at(1); + + bool broadcast_lhs = false; + bool broadcast_rhs = false; + if (lhs_data.size() != rhs_data.size()) + { + if (lhs_data.size() < rhs_data.size()) + broadcast_lhs = true; + else + broadcast_rhs = true; + } + + CircleGen cgen; + const auto output_type = circle::TensorType::TensorType_BOOL; + + int lhs = broadcast_lhs ? cgen.addTensor({{1}, param.input_type}) + : cgen.addTensor({{1, 2, 2, 1}, param.input_type}); + int rhs = broadcast_rhs ? cgen.addTensor({{1}, param.input_type}) + : cgen.addTensor({{1, 2, 2, 1}, param.input_type}); + int out = cgen.addTensor({{1, 2, 2, 1}, output_type}); + cgen.addOperatorLessEqual({{lhs, rhs}, {out}}); + cgen.setInputsAndOutputs({lhs, rhs}, {out}); + + _context = std::make_unique<GenModelTestContext>(cgen.finish()); + _context->addTestCase(param.tcd); + _context->setBackends(param.backends); + + SUCCEED(); +} + +TEST_F(GenModelTest, neg_OneOp_LessEqual_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.addOperatorLessEqual({{lhs, rhs}, {out}}); + 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_LessEqual_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.addOperatorLessEqual({{lhs, rhs}, {out}}); + cgen.setInputsAndOutputs({lhs, rhs}, {out}); + + _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/LogSoftmax.cc b/tests/nnfw_api/src/one_op_tests/LogSoftmax.test.cc index 5834fa53a..5834fa53a 100644 --- a/tests/nnfw_api/src/one_op_tests/LogSoftmax.cc +++ b/tests/nnfw_api/src/one_op_tests/LogSoftmax.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Mean.cc b/tests/nnfw_api/src/one_op_tests/Mean.test.cc index 6293d3837..6293d3837 100644 --- a/tests/nnfw_api/src/one_op_tests/Mean.cc +++ b/tests/nnfw_api/src/one_op_tests/Mean.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Mul.cc b/tests/nnfw_api/src/one_op_tests/Mul.test.cc index 0c7944613..0c7944613 100644 --- a/tests/nnfw_api/src/one_op_tests/Mul.cc +++ b/tests/nnfw_api/src/one_op_tests/Mul.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Neg.cc b/tests/nnfw_api/src/one_op_tests/Neg.test.cc index 7bc0cc452..7bc0cc452 100644 --- a/tests/nnfw_api/src/one_op_tests/Neg.cc +++ b/tests/nnfw_api/src/one_op_tests/Neg.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/NotEqual.test.cc b/tests/nnfw_api/src/one_op_tests/NotEqual.test.cc new file mode 100644 index 000000000..6a3fec150 --- /dev/null +++ b/tests/nnfw_api/src/one_op_tests/NotEqual.test.cc @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2022 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" + +struct NotEqualVariationParam +{ + TestCaseData tcd; + circle::TensorType input_type = circle::TensorType::TensorType_FLOAT32; + const std::vector<std::string> backends = {"acl_cl", "acl_neon", "cpu"}; +}; + +class NotEqualVariation : public GenModelTest, + public ::testing::WithParamInterface<NotEqualVariationParam> +{ +}; + +// Input shape: +// Base: {1, 2, 2, 1} +// Brodcast: {1} on of two input +// Output shape: {1, 2, 2, 1} +// Input type: Non-quantization type +// Output type: BOOL +// Test with different input type and value +INSTANTIATE_TEST_SUITE_P(GenModelTest, NotEqualVariation, + ::testing::Values( + // Float type + NotEqualVariationParam{TestCaseData{} + .addInput<float>({0.1, 0.3, 0.5, 0.7}) + .addInput<float>({0.1, 0.2, 0.3, 0.4}) + .addOutput<bool>({false, true, true, true})}, + // Float type - broadcast + NotEqualVariationParam{TestCaseData{} + .addInput<float>({0.1, 0.3, 0.5, 0.7}) + .addInput<float>({0.3}) + .addOutput<bool>({true, false, true, true})}, + // Int32 type + NotEqualVariationParam{TestCaseData{} + .addInput<int32_t>({1, 3, 5, 7}) + .addInput<int32_t>({1, 2, 3, 4}) + .addOutput<bool>({false, true, true, true}), + circle::TensorType::TensorType_INT32}, + // Int32 type - broadcast + NotEqualVariationParam{TestCaseData{} + .addInput<int32_t>({1, 3, 5, 7}) + .addInput<int32_t>({5}) + .addOutput<bool>({true, true, false, true}), + circle::TensorType::TensorType_INT32}, + // Int64 type + // NYI: acl backend + NotEqualVariationParam{TestCaseData{} + .addInput<int64_t>({1, 3, 5, 7}) + .addInput<int64_t>({1, 2, 3, 4}) + .addOutput<bool>({false, true, true, true}), + circle::TensorType::TensorType_INT64, + {"cpu"}}, + // Int64 type - broadcast + // NYI: acl backend + NotEqualVariationParam{TestCaseData{} + .addInput<int64_t>({1, 3, 5, 7}) + .addInput<int64_t>({1}) + .addOutput<bool>({false, true, true, true}), + circle::TensorType::TensorType_INT64, + {"cpu"}}, + // Bool type + NotEqualVariationParam{TestCaseData{} + .addInput<bool>({false, false, true, true}) + .addInput<bool>({false, true, false, true}) + .addOutput<bool>({false, true, true, false}), + circle::TensorType::TensorType_BOOL}, + // Bool type - broadcast + NotEqualVariationParam{TestCaseData{} + .addInput<bool>({false, false, true, true}) + .addInput<bool>({false}) + .addOutput<bool>({false, false, true, true}), + circle::TensorType::TensorType_BOOL} + + )); + +TEST_P(NotEqualVariation, Test) +{ + auto ¶m = GetParam(); + + auto lhs_data = param.tcd.inputs.at(0); + auto rhs_data = param.tcd.inputs.at(1); + + bool broadcast_lhs = false; + bool broadcast_rhs = false; + if (lhs_data.size() != rhs_data.size()) + { + if (lhs_data.size() < rhs_data.size()) + broadcast_lhs = true; + else + broadcast_rhs = true; + } + + CircleGen cgen; + const auto output_type = circle::TensorType::TensorType_BOOL; + + int lhs = broadcast_lhs ? cgen.addTensor({{1}, param.input_type}) + : cgen.addTensor({{1, 2, 2, 1}, param.input_type}); + int rhs = broadcast_rhs ? cgen.addTensor({{1}, param.input_type}) + : cgen.addTensor({{1, 2, 2, 1}, param.input_type}); + int out = cgen.addTensor({{1, 2, 2, 1}, output_type}); + cgen.addOperatorNotEqual({{lhs, rhs}, {out}}); + cgen.setInputsAndOutputs({lhs, rhs}, {out}); + + _context = std::make_unique<GenModelTestContext>(cgen.finish()); + _context->addTestCase(param.tcd); + _context->setBackends(param.backends); + + SUCCEED(); +} + +TEST_F(GenModelTest, neg_OneOp_NotEqual_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.addOperatorNotEqual({{lhs, rhs}, {out}}); + 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_NotEqual_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.addOperatorNotEqual({{lhs, rhs}, {out}}); + cgen.setInputsAndOutputs({lhs, rhs}, {out}); + + _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/OneHot.cc b/tests/nnfw_api/src/one_op_tests/OneHot.test.cc index 78ad35b40..78ad35b40 100644 --- a/tests/nnfw_api/src/one_op_tests/OneHot.cc +++ b/tests/nnfw_api/src/one_op_tests/OneHot.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Pad.cc b/tests/nnfw_api/src/one_op_tests/Pad.test.cc index c376c1c02..582bd84bc 100644 --- a/tests/nnfw_api/src/one_op_tests/Pad.cc +++ b/tests/nnfw_api/src/one_op_tests/Pad.test.cc @@ -32,7 +32,7 @@ class PadVariation : public GenModelTest, public ::testing::WithParamInterface<P }; // Test with different value type -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, PadVariation, ::testing::Values( // float value diff --git a/tests/nnfw_api/src/one_op_tests/PadV2.cc b/tests/nnfw_api/src/one_op_tests/PadV2.test.cc index 3db2187b2..3db2187b2 100644 --- a/tests/nnfw_api/src/one_op_tests/PadV2.cc +++ b/tests/nnfw_api/src/one_op_tests/PadV2.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Quantize.cc b/tests/nnfw_api/src/one_op_tests/Quantize.test.cc index 5ab4d6297..5ab4d6297 100644 --- a/tests/nnfw_api/src/one_op_tests/Quantize.cc +++ b/tests/nnfw_api/src/one_op_tests/Quantize.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Rank.cc b/tests/nnfw_api/src/one_op_tests/Rank.test.cc index 60ec1931a..60ec1931a 100644 --- a/tests/nnfw_api/src/one_op_tests/Rank.cc +++ b/tests/nnfw_api/src/one_op_tests/Rank.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Reduce.cc b/tests/nnfw_api/src/one_op_tests/Reduce.test.cc index bdcc5c225..13d180aed 100644 --- a/tests/nnfw_api/src/one_op_tests/Reduce.cc +++ b/tests/nnfw_api/src/one_op_tests/Reduce.test.cc @@ -63,8 +63,8 @@ TEST_P(ReduceMaxBadIndex, neg_Test) SUCCEED(); } -INSTANTIATE_TEST_CASE_P(GenModelTest, ReduceMaxBadIndex, - ::testing::Values(std::vector<int32_t>{0, 1, 2, 4}, - std::vector<int32_t>{0, -5, 2, 3}, - std::vector<int32_t>{-88, 1, 2, 3}, - std::vector<int32_t>{0, 1, 88, 3})); +INSTANTIATE_TEST_SUITE_P(GenModelTest, ReduceMaxBadIndex, + ::testing::Values(std::vector<int32_t>{0, 1, 2, 4}, + std::vector<int32_t>{0, -5, 2, 3}, + std::vector<int32_t>{-88, 1, 2, 3}, + std::vector<int32_t>{0, 1, 88, 3})); diff --git a/tests/nnfw_api/src/one_op_tests/Relu.cc b/tests/nnfw_api/src/one_op_tests/Relu.test.cc index 28c511270..28c511270 100644 --- a/tests/nnfw_api/src/one_op_tests/Relu.cc +++ b/tests/nnfw_api/src/one_op_tests/Relu.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Relu6.cc b/tests/nnfw_api/src/one_op_tests/Relu6.test.cc index 88b8eba83..88b8eba83 100644 --- a/tests/nnfw_api/src/one_op_tests/Relu6.cc +++ b/tests/nnfw_api/src/one_op_tests/Relu6.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/ResizeBilinear.cc b/tests/nnfw_api/src/one_op_tests/ResizeBilinear.test.cc index 5db08f168..fe313d4e7 100644 --- a/tests/nnfw_api/src/one_op_tests/ResizeBilinear.cc +++ b/tests/nnfw_api/src/one_op_tests/ResizeBilinear.test.cc @@ -51,7 +51,7 @@ TEST_P(ResizeBilinearVariation, Test) SUCCEED(); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, ResizeBilinearVariation, ::testing::Values( // float value diff --git a/tests/nnfw_api/src/one_op_tests/ResizeNearestNeighbor.cc b/tests/nnfw_api/src/one_op_tests/ResizeNearestNeighbor.test.cc index 1dd65844b..1dd65844b 100644 --- a/tests/nnfw_api/src/one_op_tests/ResizeNearestNeighbor.cc +++ b/tests/nnfw_api/src/one_op_tests/ResizeNearestNeighbor.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Reverse.cc b/tests/nnfw_api/src/one_op_tests/Reverse.test.cc index 4168b2123..4168b2123 100644 --- a/tests/nnfw_api/src/one_op_tests/Reverse.cc +++ b/tests/nnfw_api/src/one_op_tests/Reverse.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Select.cc b/tests/nnfw_api/src/one_op_tests/Select.test.cc index e1d991877..e1d991877 100644 --- a/tests/nnfw_api/src/one_op_tests/Select.cc +++ b/tests/nnfw_api/src/one_op_tests/Select.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Shape.cc b/tests/nnfw_api/src/one_op_tests/Shape.test.cc index 2a73db99a..2a73db99a 100644 --- a/tests/nnfw_api/src/one_op_tests/Shape.cc +++ b/tests/nnfw_api/src/one_op_tests/Shape.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Slice.cc b/tests/nnfw_api/src/one_op_tests/Slice.test.cc index 002fb0132..8cd9d7037 100644 --- a/tests/nnfw_api/src/one_op_tests/Slice.cc +++ b/tests/nnfw_api/src/one_op_tests/Slice.test.cc @@ -34,7 +34,7 @@ class SliceVariation : public GenModelTest, { }; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, SliceVariation, ::testing::Values( SliceVariationParam{ diff --git a/tests/nnfw_api/src/one_op_tests/Softmax.cc b/tests/nnfw_api/src/one_op_tests/Softmax.test.cc index aba4e89a0..1782baf64 100644 --- a/tests/nnfw_api/src/one_op_tests/Softmax.cc +++ b/tests/nnfw_api/src/one_op_tests/Softmax.test.cc @@ -31,7 +31,7 @@ class SoftmaxVariation : public GenModelTest, public ::testing::WithParamInterfa }; // Test with different value type -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( GenModelTest, SoftmaxVariation, ::testing::Values( // float value diff --git a/tests/nnfw_api/src/one_op_tests/Split.cc b/tests/nnfw_api/src/one_op_tests/Split.test.cc index 32be9a767..32be9a767 100644 --- a/tests/nnfw_api/src/one_op_tests/Split.cc +++ b/tests/nnfw_api/src/one_op_tests/Split.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Sqrt.cc b/tests/nnfw_api/src/one_op_tests/Sqrt.test.cc index 01f313371..01f313371 100644 --- a/tests/nnfw_api/src/one_op_tests/Sqrt.cc +++ b/tests/nnfw_api/src/one_op_tests/Sqrt.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Square.cc b/tests/nnfw_api/src/one_op_tests/Square.test.cc index 2ec9bad0d..2ec9bad0d 100644 --- a/tests/nnfw_api/src/one_op_tests/Square.cc +++ b/tests/nnfw_api/src/one_op_tests/Square.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/StridedSlice.cc b/tests/nnfw_api/src/one_op_tests/StridedSlice.test.cc index fb29018d4..fb29018d4 100644 --- a/tests/nnfw_api/src/one_op_tests/StridedSlice.cc +++ b/tests/nnfw_api/src/one_op_tests/StridedSlice.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Sub.cc b/tests/nnfw_api/src/one_op_tests/Sub.test.cc index bb4fecd2d..bb4fecd2d 100644 --- a/tests/nnfw_api/src/one_op_tests/Sub.cc +++ b/tests/nnfw_api/src/one_op_tests/Sub.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Tile.cc b/tests/nnfw_api/src/one_op_tests/Tile.test.cc index 3f193d5e6..3f193d5e6 100644 --- a/tests/nnfw_api/src/one_op_tests/Tile.cc +++ b/tests/nnfw_api/src/one_op_tests/Tile.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/Transpose.cc b/tests/nnfw_api/src/one_op_tests/Transpose.test.cc index 5a92c7303..5a92c7303 100644 --- a/tests/nnfw_api/src/one_op_tests/Transpose.cc +++ b/tests/nnfw_api/src/one_op_tests/Transpose.test.cc diff --git a/tests/nnfw_api/src/one_op_tests/While.cc b/tests/nnfw_api/src/one_op_tests/While.test.cc index ee0a9df46..5c4da552c 100644 --- a/tests/nnfw_api/src/one_op_tests/While.cc +++ b/tests/nnfw_api/src/one_op_tests/While.test.cc @@ -213,10 +213,10 @@ TEST_P(WhileWrongSubgraphIndex, neg_Test) 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))); +INSTANTIATE_TEST_SUITE_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))); // In this test, output of WHILE and body subgraph have different data types TEST_F(GenModelTest, neg_while_wrong_dtype) @@ -261,10 +261,10 @@ TEST_F(GenModelTest, neg_while_wrong_dtype) } _context = std::make_unique<GenModelTestContext>(cgen.finish()); - auto tc = uniformTCD<float>({{0}}, {{100}}); - tc.expectFailRun(); - _context->addTestCase(tc); _context->setBackends({"cpu"}); + // It is correct to call `_context->expectFailModelLoad();`, but OperationValidator does not deal + // with subgraphs. So it is verified by `_context->expectFailCompile(); as a workaround` + _context->expectFailCompile(); SUCCEED(); } diff --git a/tests/scripts/command/nnpkg-test b/tests/scripts/command/nnpkg-test index a1176d153..ba712175e 100644 --- a/tests/scripts/command/nnpkg-test +++ b/tests/scripts/command/nnpkg-test @@ -12,6 +12,7 @@ outdir="." nnpkg_run=${nnpkg_run:-"nnpackage_run"} difftool=${difftool:-"h5diff"} delete_dumped_on_failure=0 +verbose_diff=0 usage() { echo "Usage: $0 $progname [options] nnpackage_test" @@ -27,6 +28,7 @@ usage() { echo " -o set output directory (default=$outdir)" echo " -d delete dumped file on failure." echo " (dumped file are always deleted on success) (default=$delete_dumped_on_failure)" + echo " -v verbose result diff (default=$verbose_diff)" echo "" echo "Environment variables:" echo " nnpackage_run path to nnpackage_run (default=nnpackage_run)" @@ -43,12 +45,13 @@ if [ $# -eq 0 ]; then exit 1 fi -while getopts "hdi:o:" OPTION; do +while getopts "hdi:o:v" OPTION; do case "${OPTION}" in h) usage;; d) delete_dumped_on_failure=1;; i) indir=$OPTARG;; o) outdir=$OPTARG;; + v) verbose_diff=1;; ?) exit 1;; esac done @@ -110,8 +113,8 @@ echo -n "[Compare] $nnpkg " test_fail() { echo -e "\tFail" - [ $delete_dumped_on_failure ] && rm "$dumped" - cat "$dumped.log" + [ $delete_dumped_on_failure -eq 1 ] && rm "$dumped" + [ $verbose_diff -eq 1 ] && cat "$dumped.log" rm "$dumped.log" exit 3 } @@ -119,7 +122,7 @@ test_fail() test_pass() { echo -e "\tPass" - cat "$dumped.log" + [ $verbose_diff -eq 1 ] && cat "$dumped.log" rm "$dumped" "$dumped.log" } diff --git a/tests/scripts/command/prepare-model b/tests/scripts/command/prepare-model index 5b3340813..7c6525491 100644 --- a/tests/scripts/command/prepare-model +++ b/tests/scripts/command/prepare-model @@ -24,8 +24,8 @@ function Usage() echo "Usage: $0 $(basename ${BASH_SOURCE[0]}) [OPTIONS]" echo "" echo "Options:" - echo " --ignoremd5 Ignore MD5 check when download model files" - echo " --model=(all|nnpackage|tflite) Download test model (deprecated option: always all)" + echo " --ignoremd5 Ignore MD5 check when download model files" + echo " -h, --help Display this help message and exit" } for i in "$@" @@ -38,9 +38,6 @@ do --ignoremd5) MD5_CHECK="off" ;; - --model=*) - # deprecated - ;; *) echo "Unknown option: $i" exit 1 @@ -49,9 +46,10 @@ do shift done -# Default download server url +# Check MODELFILE_SERVER if [[ -z "$MODELFILE_SERVER" ]]; then - export MODELFILE_SERVER="http://npu.mooo.com/archive/tflite_test_model/" + echo "Fail to download models: Please set MODELFILE_SERVER to download model" + exit 1 fi echo "Download from $MODELFILE_SERVER" diff --git a/tests/tools/nnpackage_run/src/nnpackage_run.cc b/tests/tools/nnpackage_run/src/nnpackage_run.cc index 71d8b5977..7a58053f3 100644 --- a/tests/tools/nnpackage_run/src/nnpackage_run.cc +++ b/tests/tools/nnpackage_run/src/nnpackage_run.cc @@ -29,6 +29,7 @@ #include "ruy/profiler/profiler.h" #endif +#include <boost/program_options.hpp> #include <cassert> #include <chrono> #include <cstdlib> @@ -313,6 +314,11 @@ int main(const int argc, char **argv) return 0; } + catch (boost::program_options::error &e) + { + std::cerr << "E: " << e.what() << std::endl; + exit(-1); + } catch (std::runtime_error &e) { std::cerr << "E: Fail to run by runtime error:" << e.what() << std::endl; diff --git a/tests/tools/nnpackage_run/src/rawformatter.cc b/tests/tools/nnpackage_run/src/rawformatter.cc index f90018e56..e4b977485 100644 --- a/tests/tools/nnpackage_run/src/rawformatter.cc +++ b/tests/tools/nnpackage_run/src/rawformatter.cc @@ -29,14 +29,13 @@ void RawFormatter::loadInputs(const std::string &filename, std::vector<Allocatio uint32_t num_inputs; NNPR_ENSURE_STATUS(nnfw_input_size(session_, &num_inputs)); - // TODO: Support multiple inputs - // Option 1. Get comman-separated input file list like --load:raw in.0,in.1,in.2 - // Option 2. Get prefix --load:raw out - // Internally access out.0, out.1, out.2, ... out.{N} where N is determined by api. - if (num_inputs != 1) - { - throw std::runtime_error("Only 1 input is supported for raw input"); - } + // Support multiple inputs + // Option 1: Get comman-separated input file list like --load:raw a,b,c + // Option 2: Get prefix --load:raw in + // Internally access in.0, in.1, in.2, ... in.{N-1} where N is determined by nnfw info + // query api. + // + // Currently Option 2 is implemented. try { for (uint32_t i = 0; i < num_inputs; ++i) @@ -48,11 +47,12 @@ void RawFormatter::loadInputs(const std::string &filename, std::vector<Allocatio auto bufsz = bufsize_for(&ti); inputs[i].alloc(bufsz); - std::ifstream file(filename, std::ios::ate | std::ios::binary); + std::ifstream file(filename + "." + std::to_string(i), std::ios::ate | std::ios::binary); auto filesz = file.tellg(); if (bufsz != filesz) { - throw std::runtime_error("Input Size does not match: " + std::to_string(bufsz) + + throw std::runtime_error("Input " + std::to_string(i) + + " size does not match: " + std::to_string(bufsz) + " expected, but " + std::to_string(filesz) + " provided."); } file.seekg(0, std::ios::beg); @@ -74,12 +74,6 @@ void RawFormatter::dumpOutputs(const std::string &filename, std::vector<Allocati { uint32_t num_outputs; NNPR_ENSURE_STATUS(nnfw_output_size(session_, &num_outputs)); - // TODO: Support multiple outputs - // Available options are same. - if (num_outputs != 1) - { - throw std::runtime_error("Only 1 output is supported for raw input"); - } try { for (uint32_t i = 0; i < num_outputs; i++) diff --git a/tests/tools/tflite_vanilla_run/CMakeLists.txt b/tests/tools/tflite_vanilla_run/CMakeLists.txt index a673058a4..115b2f386 100644 --- a/tests/tools/tflite_vanilla_run/CMakeLists.txt +++ b/tests/tools/tflite_vanilla_run/CMakeLists.txt @@ -2,12 +2,13 @@ if(NOT BUILD_TFLITE_VANILLA_RUN) return() endif() -if(NOT BUILD_TENSORFLOW_LITE_2_3_0) - set(BUILD_TENSORFLOW_LITE_2_3_0 ON) +if(NOT BUILD_TENSORFLOW_LITE_2_8_0) + set(BUILD_TENSORFLOW_LITE_2_8_0 ON) + set(BUILD_TENSORFLOWRUY ON) endif() -nnfw_find_package(TensorFlowLite EXACT 2.3.0 REQUIRED) -nnfw_find_package(Boost REQUIRED) +nnfw_find_package(TensorFlowLite EXACT 2.8.0 REQUIRED) +nnfw_find_package(Boost REQUIRED program_options) list(APPEND TFLITE_RUN_SRCS "src/tflite_vanilla_run.cc") list(APPEND TFLITE_RUN_SRCS "src/args.cc") @@ -16,7 +17,7 @@ add_executable(tflite_vanilla_run ${TFLITE_RUN_SRCS}) target_include_directories(tflite_vanilla_run PRIVATE src) target_include_directories(tflite_vanilla_run PRIVATE ${Boost_INCLUDE_DIRS}) -target_link_libraries(tflite_vanilla_run tensorflow-lite-2.3.0 ${LIB_PTHREAD} dl) +target_link_libraries(tflite_vanilla_run tensorflow-lite-2.8.0 ${LIB_PTHREAD} dl) target_link_libraries(tflite_vanilla_run ${Boost_PROGRAM_OPTIONS_LIBRARY}) target_link_libraries(tflite_vanilla_run nnfw_lib_benchmark nnfw_lib_misc) diff --git a/tests/tools/tflite_vanilla_run/src/tflite_vanilla_run.cc b/tests/tools/tflite_vanilla_run/src/tflite_vanilla_run.cc index 77b5e7a37..6194b4505 100644 --- a/tests/tools/tflite_vanilla_run/src/tflite_vanilla_run.cc +++ b/tests/tools/tflite_vanilla_run/src/tflite_vanilla_run.cc @@ -16,6 +16,7 @@ #include "tensorflow/lite/model.h" #include "tensorflow/lite/kernels/register.h" +#include "tensorflow/lite/delegates/nnapi/nnapi_delegate.h" #include "args.h" #include "tensor_view.h" @@ -128,7 +129,11 @@ int main(const int argc, char **argv) try { phases.run("PREPARE", [&](const benchmark::Phase &, uint32_t) { - interpreter->UseNNAPI(use_nnapi); + if (use_nnapi) + { + // TFLite NNAPI is not worked yet + interpreter->ModifyGraphWithDelegate(tflite::NnApiDelegate()); + } interpreter->AllocateTensors(); }); } |