12 #include <boost/test/unit_test.hpp> 18 using namespace armnn;
24 explicit DepthwiseConvolution2dFixture(
const std::string& dataLayout,
const char* paddingType)
26 m_Prototext =
"node { \n" 27 " name: \"graphInput\" \n" 28 " op: \"Placeholder\" \n" 44 " name: \"Const_1\" \n" 71 " tensor_content: \"\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?" 72 "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?" 73 "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?" 74 "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?" 75 "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?" 76 "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?" 77 "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?" 78 "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?" 79 "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?\" \n" 85 " name: \"potato\" \n" 86 " op: \"DepthwiseConv2dNative\" \n" 87 " input: \"graphInput\" \n" 88 " input: \"Const_1\" \n" 96 " key: \"data_format\" \n" 99 m_Prototext.append(dataLayout);
100 m_Prototext.append(
"\"\n" 104 " key: \"padding\" \n" 107 m_Prototext.append(paddingType);
108 m_Prototext.append(
"\"\n" 112 " key: \"strides\" \n" 123 " key: \"use_cudnn_on_gpu\" \n" 130 if(dataLayout ==
"NHWC")
132 SetupSingleInputSingleOutput({ 1u, 1u, 3u, 3u },
"graphInput",
"potato");
136 SetupSingleInputSingleOutput({ 1u, 3u, 1u, 3u },
"graphInput",
"potato");
141 struct DepthwiseConvolution2dNhwcSameFixture : DepthwiseConvolution2dFixture
143 DepthwiseConvolution2dNhwcSameFixture() : DepthwiseConvolution2dFixture(
"NHWC",
"SAME") { }
148 RunTest<4>({ 1, 2, 3, 4, 5, 6, 7, 8, 9 },
149 { 2.5f, 5.f, 2.5f, 3.5f, 7.f, 3.5f, 4.5f, 9.f, 4.5f,
150 6.f, 12.f, 6.f, 7.5f, 15.f, 7.5f, 9.f, 18.f, 9.f,
151 5.5f, 11.f, 5.5f, 6.5f, 13.f, 6.5f, 7.5f, 15.f, 7.5f });
154 struct DepthwiseConvolution2dNchwSameFixture : DepthwiseConvolution2dFixture
156 DepthwiseConvolution2dNchwSameFixture() : DepthwiseConvolution2dFixture(
"NCHW",
"SAME") { }
161 RunTest<4>({ 1, 4, 7, 2, 5, 8, 3, 6, 9 },
162 { 2.5f, 6.f, 5.5f, 5.f, 12.f, 11.f, 2.5f, 6.f, 5.5f,
163 3.5f, 7.5f, 6.5f, 7.f, 15.f, 13.f, 3.5f, 7.5f, 6.5f,
164 4.5f, 9.f, 7.5f, 9.f, 18.f, 15.f, 4.5f, 9.f, 7.5f });
167 struct DepthwiseConvolution2dNhwcValidFixture : DepthwiseConvolution2dFixture
169 DepthwiseConvolution2dNhwcValidFixture() : DepthwiseConvolution2dFixture(
"NHWC",
"VALID") { }
174 RunTest<4>({ 1, 2, 3, 4, 5, 6, 7, 8, 9 },
175 { 6.f, 12.f, 6.f, 7.5f, 15.f, 7.5f, 9.f, 18.f, 9.f });
178 struct DepthwiseConvolution2dNchwValidFixture : DepthwiseConvolution2dFixture
180 DepthwiseConvolution2dNchwValidFixture() : DepthwiseConvolution2dFixture(
"NCHW",
"VALID") { }
185 RunTest<4>({ 1, 4, 7, 2, 5, 8, 3, 6, 9 },
186 { 6.f, 12.f, 6.f, 7.5f, 15.f, 7.5f, 9.f, 18.f, 9.f });
BOOST_FIXTURE_TEST_CASE(ParseDepthwiseConv2DNhwcSame, DepthwiseConvolution2dNhwcSameFixture)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)