Skip to content

Commit

Permalink
[onert] Revisit DepthwiseConv2D nnfw_api test
Browse files Browse the repository at this point in the history
This commit renames test cases to be simple and adds test cases related
to Bias and Multiplier.

ONE-DCO-1.0-Signed-off-by: Jiyoung Yun <[email protected]>
  • Loading branch information
jyoungyun committed Jul 30, 2024
1 parent 19b0b2b commit e86003b
Showing 1 changed file with 36 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,26 @@
TEST_F(GenModelTest, OneOp_DepthwiseConv2D)
{
CircleGen cgen;
std::vector<float> weight_data{1, 2, 3, 4, -9, 10, -11, 12, 5, 6, 7, 8, 13, -14, 15, -16};
std::vector<float> weight_data{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f};
uint32_t weight_buf = cgen.addBuffer(weight_data);
std::vector<float> bias_data{1, 2, 3, 4};
std::vector<float> 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<GenModelTestContext>(cgen.finish());
_context->addTestCase(uniformTCD<float>({{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<float>({{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<float> weight_data{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f};
Expand All @@ -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<float> 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<float> 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<GenModelTestContext>(cgen.finish());
_context->addTestCase(uniformTCD<float>({{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<float> weight_data{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f};
Expand Down

0 comments on commit e86003b

Please sign in to comment.