MCPcopy Create free account
hub / github.com/ARM-software/armnn / CreateDepthwiseConvolution2dGraph

Function CreateDepthwiseConvolution2dGraph

src/armnn/test/OptimizerTests.cpp:480–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

478}
479
480void CreateDepthwiseConvolution2dGraph(Graph &graph, const unsigned int* inputShape,
481 const unsigned int* weightsShape, const unsigned int* outputShape,
482 DataLayout dataLayout = DataLayout::NCHW)
483{
484 armnn::TensorInfo inputInfo(4, inputShape, DataType::Float32);
485 armnn::TensorInfo outputInfo(4, outputShape, DataType::Float32);
486 armnn::TensorInfo weightsInfo(TensorShape(4, weightsShape), armnn::DataType::Float32, 0.0f, 0, true);
487
488 std::vector<float> weightsVector(18);
489 armnn::ConstTensor weights(weightsInfo, weightsVector);
490
491 DepthwiseConvolution2dDescriptor desc;
492 desc.m_BiasEnabled = false;
493 desc.m_StrideX = 1;
494 desc.m_StrideY = 1;
495 desc.m_DataLayout = dataLayout;
496
497 InputLayer* input = graph.AddLayer<InputLayer>(0, "input");
498 DepthwiseConvolution2dLayer* layer = graph.AddLayer<DepthwiseConvolution2dLayer>(desc, "depthwiseConv2d");
499 ConstantLayer* weightsLayer = graph.AddLayer<ConstantLayer>("weights");
500 OutputLayer* output = graph.AddLayer<OutputLayer>(0, "output");
501
502 input->GetOutputSlot().SetTensorInfo(inputInfo);
503 layer->GetOutputSlot().SetTensorInfo(outputInfo);
504 weightsLayer->GetOutputSlot().SetTensorInfo(weightsInfo);
505
506 weightsLayer->m_LayerOutput = std::make_unique<armnn::ScopedTensorHandle>(weights);
507
508 input->GetOutputSlot().Connect(layer->GetInputSlot(0));
509 weightsLayer->GetOutputSlot().Connect(layer->GetInputSlot(1));
510 layer->GetOutputSlot().Connect(output->GetInputSlot(0));
511}
512
513TEST_CASE("DepthwiseConv2dValidateTensorShapesFromInputs")
514{

Callers 1

OptimizerTests.cppFile · 0.85

Calls 4

GetOutputSlotMethod · 0.80
TensorShapeClass · 0.50
SetTensorInfoMethod · 0.45
ConnectMethod · 0.45

Tested by

no test coverage detected