diff --git a/tests/nnfw_api/src/GenModelTests/one_op_tests/DepthwiseConv2D.test.cc b/tests/nnfw_api/src/GenModelTests/one_op_tests/DepthwiseConv2D.test.cc index 92833244876..59e07e07d72 100644 --- a/tests/nnfw_api/src/GenModelTests/one_op_tests/DepthwiseConv2D.test.cc +++ b/tests/nnfw_api/src/GenModelTests/one_op_tests/DepthwiseConv2D.test.cc @@ -19,27 +19,26 @@ TEST_F(GenModelTest, OneOp_DepthwiseConv2D) { CircleGen cgen; - std::vector weight_data{1, 2, 3, 4, -9, 10, -11, 12, 5, 6, 7, 8, 13, -14, 15, -16}; + std::vector weight_data{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}; uint32_t weight_buf = cgen.addBuffer(weight_data); - std::vector bias_data{1, 2, 3, 4}; + std::vector bias_data{0, 0}; uint32_t bias_buf = cgen.addBuffer(bias_data); - int in = cgen.addTensor({{1, 3, 2, 2}, circle::TensorType::TensorType_FLOAT32}); - int weight = cgen.addTensor({{1, 2, 2, 4}, circle::TensorType::TensorType_FLOAT32, weight_buf}); - int bias = cgen.addTensor({{4}, circle::TensorType::TensorType_FLOAT32, bias_buf}); - int out = cgen.addTensor({{1, 2, 1, 4}, circle::TensorType::TensorType_FLOAT32}); - cgen.addOperatorDepthwiseConv2D({{in, weight, bias}, {out}}, circle::Padding_VALID, 1, 1, 2, + int in = cgen.addTensor({{1, 2, 2, 2}, circle::TensorType::TensorType_FLOAT32}); + int weight = cgen.addTensor({{1, 3, 1, 2}, circle::TensorType::TensorType_FLOAT32, weight_buf}); + int bias = cgen.addTensor({{2}, circle::TensorType::TensorType_FLOAT32, bias_buf}); + int out = cgen.addTensor({{1, 2, 2, 2}, circle::TensorType::TensorType_FLOAT32}); + cgen.addOperatorDepthwiseConv2D({{in, weight, bias}, {out}}, circle::Padding_SAME, 1, 1, 1, circle::ActivationFunctionType_NONE); cgen.setInputsAndOutputs({in}, {out}); _context = std::make_unique(cgen.finish()); - _context->addTestCase(uniformTCD({{1, 2, 7, 8, 3, 4, 9, 10, 5, 6, 11, 12}}, - {{71, -34, 99, -20, 91, -26, 127, -4}})); - _context->setBackends({"acl_cl", "acl_neon", "cpu", "xnnpack"}); - + _context->addTestCase(uniformTCD({{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f}}, + {{16.0, 28.0, 28.0, 44.0, 8.0, 16.0, 12.0, 24.0}})); + _context->setBackends({"acl_cl", "acl_neon", "cpu", "gpu_cl"}); SUCCEED(); } -TEST_F(GenModelTest, OneOp_DepthwiseConv2D_No_Multiplier) +TEST_F(GenModelTest, OneOp_DepthwiseConv2D_Bias) { CircleGen cgen; std::vector weight_data{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f}; @@ -62,7 +61,31 @@ TEST_F(GenModelTest, OneOp_DepthwiseConv2D_No_Multiplier) SUCCEED(); } -TEST_F(GenModelTest, OneOp_DepthwiseConv2D_No_Multiplier_RELU6) +TEST_F(GenModelTest, OneOp_DepthwiseConv2D_Muliplier) +{ + CircleGen cgen; + std::vector weight_data{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, + -5.0f, -4.0f, -3.0f, -2.0f, -1.0f, 0.0}; + uint32_t weight_buf = cgen.addBuffer(weight_data); + std::vector bias_data{0.5f, -0.5f, 0.3f, -0.3f}; + uint32_t bias_buf = cgen.addBuffer(bias_data); + int in = cgen.addTensor({{1, 2, 2, 2}, circle::TensorType::TensorType_FLOAT32}); + int weight = cgen.addTensor({{1, 3, 1, 4}, circle::TensorType::TensorType_FLOAT32, weight_buf}); + int bias = cgen.addTensor({{4}, circle::TensorType::TensorType_FLOAT32, bias_buf}); + int out = cgen.addTensor({{1, 2, 2, 4}, circle::TensorType::TensorType_FLOAT32}); + cgen.addOperatorDepthwiseConv2D({{in, weight, bias}, {out}}, circle::Padding_SAME, 1, 1, 2, + circle::ActivationFunctionType_NONE); + cgen.setInputsAndOutputs({in}, {out}); + + _context = std::make_unique(cgen.finish()); + _context->addTestCase(uniformTCD({{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f}}, + {{-11.5, -8.5, -9.7, -4.3, -9.5, -2.5, -21.7, -12.3, 16.5, + 19.5, -22.7, -17.3, 24.5, 31.5, -28.7, -19.3}})); + _context->setBackends({"acl_cl", "acl_neon", "cpu", "gpu_cl"}); + SUCCEED(); +} + +TEST_F(GenModelTest, OneOp_DepthwiseConv2D_RELU6) { CircleGen cgen; std::vector weight_data{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f};