@@ -34,19 +34,19 @@ SubgraphPortsMap::const_iterator findLayer(const SubgraphPortsMap& inputs, const
34
34
35
35
// Add an ConditionalInputLayer between `layer` and its inputs.
36
36
// I.e. input[inIdx] -> layer ==> input[inIdx] -> ConditionalInputLayer -> layer.
37
- Status addConditionalInputLayer (ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
37
+ void addConditionalInputLayer (ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
38
38
nvinfer1::ILayer& layer, int32_t inIdx)
39
39
{
40
40
auto input = layer.getInput (inIdx);
41
41
if (input == nullptr )
42
42
{
43
43
// Phantom input (an input that is really constant weights).
44
- return Status::success () ;
44
+ return ;
45
45
}
46
46
47
47
if (layer.getType () == nvinfer1::LayerType::kCONDITIONAL_OUTPUT )
48
48
{
49
- return Status::success () ;
49
+ return ;
50
50
}
51
51
52
52
auto const name = input->getName ();
@@ -70,12 +70,11 @@ Status addConditionalInputLayer(ImporterContext* ctx, nvinfer1::IIfConditional*
70
70
}
71
71
auto ifOutput = N_CHECK (inputLayer->getOutput (0 ));
72
72
layer.setInput (inIdx, *ifOutput);
73
- return Status::success ();
74
73
};
75
74
76
75
// Take a snapshot of the network before and after parsing the subgraph and return a list
77
76
// of newly added network layers.
78
- Status importSubgraph (ImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const & subgraph,
77
+ void importSubgraph (ImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const & subgraph,
79
78
std::vector<nvinfer1::ILayer*>& newLayers, std::vector<TensorOrWeights>& subgraphTensors)
80
79
{
81
80
auto net = ctx->network ();
@@ -85,7 +84,7 @@ Status importSubgraph(ImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const&
85
84
NameScope nameScope (*ctx);
86
85
87
86
std::vector<Status> errors{};
88
- CHECK_STATUS ( onnx2trt::parseGraph (ctx, subgraph, errors) );
87
+ onnx2trt::parseGraph (ctx, subgraph, errors);
89
88
90
89
for (int32_t i = 0 ; i < subgraph.output_size (); ++i)
91
90
{
@@ -97,12 +96,10 @@ Status importSubgraph(ImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const&
97
96
{
98
97
newLayers.push_back (net->getLayer (i));
99
98
}
100
-
101
- return Status::success ();
102
99
}
103
100
104
101
// Add an IConditionalInputLayer to `layer`'s inputs, if they don't already exist.
105
- Status addConditionalInputIfNeeded (ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
102
+ void addConditionalInputIfNeeded (ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
106
103
nvinfer1::ILayer& layer, SubgraphPortsMap subgraphInputsMap)
107
104
{
108
105
// Return all of the layer's inputs that are external to the subgraph that
@@ -125,11 +122,10 @@ Status addConditionalInputIfNeeded(ImporterContext* ctx, nvinfer1::IIfConditiona
125
122
LOG_VERBOSE (" Adding Input layer for " << layer.getName ());
126
123
addConditionalInputLayer (ctx, conditional, inputsMap, layer, inIdx);
127
124
}
128
- return Status::success ();
129
125
}
130
126
131
127
// Add IConditionalInputLayers to `layer`'s inputs.
132
- Status addIfInputLayers (ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
128
+ void addIfInputLayers (ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
133
129
const std::vector<nvinfer1::ILayer*>& newLayers)
134
130
{
135
131
// Find all of the tensors entering the subgraph.
@@ -143,12 +139,10 @@ Status addIfInputLayers(ImporterContext* ctx, nvinfer1::IIfConditional* conditio
143
139
{
144
140
addConditionalInputIfNeeded (ctx, conditional, inputsMap, *layer, subgraphInputsMap);
145
141
}
146
-
147
- return Status::success ();
148
142
}
149
143
150
144
// Given a subgraph, find all of its external inputs/outputs (tensors entering/exiting the subgraph).
151
- Status getSubgraphTensors (const std::vector<nvinfer1::ILayer*>& newLayers,
145
+ void getSubgraphTensors (const std::vector<nvinfer1::ILayer*>& newLayers,
152
146
std::unordered_map<nvinfer1::ITensor*, std::set<int32_t >>& externalOutputs, bool extractOutputs,
153
147
const std::vector<std::string>* reportedOutputs = nullptr )
154
148
{
@@ -255,20 +249,19 @@ Status getSubgraphTensors(const std::vector<nvinfer1::ILayer*>& newLayers,
255
249
externalOutputs[tensor].insert (portIndex);
256
250
}
257
251
}
258
- return Status::success ();
259
252
}
260
253
261
- Status getSubgraphOutputs (const std::vector<nvinfer1::ILayer*>& newLayers,
254
+ void getSubgraphOutputs (const std::vector<nvinfer1::ILayer*>& newLayers,
262
255
std::unordered_map<nvinfer1::ITensor*, std::set<int32_t >>& externalOutputs,
263
256
const std::vector<std::string>& reportedOutputs)
264
257
{
265
- return getSubgraphTensors (newLayers, externalOutputs, true , &reportedOutputs);
258
+ getSubgraphTensors (newLayers, externalOutputs, true , &reportedOutputs);
266
259
}
267
260
268
- Status getSubgraphInputs (const std::vector<nvinfer1::ILayer*>& newLayers,
261
+ void getSubgraphInputs (const std::vector<nvinfer1::ILayer*>& newLayers,
269
262
std::unordered_map<nvinfer1::ITensor*, std::set<int32_t >>& externalInputs)
270
263
{
271
- return getSubgraphTensors (newLayers, externalInputs, false );
264
+ getSubgraphTensors (newLayers, externalInputs, false );
272
265
}
273
266
274
267
} // namespace onnx2trt
0 commit comments