MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / parseConcat

Function parseConcat

parsers/caffe/caffeParser/opParsers/parseConcat.cpp:24–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22namespace nvcaffeparser1
23{
24ILayer* parseConcat(INetworkDefinition& network, const trtcaffe::LayerParameter& msg, CaffeWeightFactory& /*weightFactory*/, BlobNameToTensor& tensors)
25{
26 const trtcaffe::ConcatParameter& p = msg.concat_param();
27 bool hasAxis = p.has_axis(); // optional parameter
28
29 if (hasAxis && p.axis() < 0)
30 {
31 std::cout << "Caffe parser: Concat negative axis is not supported." << std::endl;
32 return nullptr;
33 }
34 if (network.hasImplicitBatchDimension() && p.axis() == 0)
35 {
36 std::cout << "Caffe parser: Concat across batch axis with implicit batch dimensions is not supported."
37 << std::endl;
38 return nullptr;
39 }
40
41 std::vector<ITensor*> ptrs;
42 for (unsigned int i = 0, n = msg.bottom_size(); i < n; i++)
43 {
44 ptrs.push_back(tensors[msg.bottom().Get(i)]);
45 }
46
47 auto concat = network.addConcatenation(&ptrs[0], msg.bottom_size());
48
49 // If no axis is explicitly provided, do not call setAxis.
50 // Rely on the default axis setting inside TRT which takes into account NPCHW and higher dimensional input.
51 if (hasAxis)
52 {
53 concat->setAxis(p.axis() - static_cast<int>(network.hasImplicitBatchDimension()));
54 }
55
56 return concat;
57}
58} //namespace nvcaffeparser1

Callers

nothing calls this directly

Calls 4

addConcatenationMethod · 0.80
axisMethod · 0.45
setAxisMethod · 0.45

Tested by

no test coverage detected