Skip to content

Commit 973d68d

Browse files
10.0 Release Updates (#960)
* 10.0 Release Updates Signed-off-by: Asfiya Baig <[email protected]> --------- Signed-off-by: Asfiya Baig <[email protected]>
1 parent 1def182 commit 973d68d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4852
-3634
lines changed

CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ add_definitions("-DSOURCE_LENGTH=${SOURCE_LENGTH}")
2727
#--------------------------------------------------
2828
# Version information
2929
#--------------------------------------------------
30-
set(ONNX2TRT_MAJOR 9)
31-
set(ONNX2TRT_MINOR 3)
30+
set(ONNX2TRT_MAJOR 10)
31+
set(ONNX2TRT_MINOR 0)
3232
set(ONNX2TRT_PATCH 0)
3333
set(ONNX2TRT_VERSION "${ONNX2TRT_MAJOR}.${ONNX2TRT_MINOR}.${ONNX2TRT_PATCH}" CACHE STRING "ONNX2TRT version")
3434

@@ -39,10 +39,10 @@ set(ONNX2TRT_VERSION "${ONNX2TRT_MAJOR}.${ONNX2TRT_MINOR}.${ONNX2TRT_PATCH}" CAC
3939
set(IMPORTER_SOURCES
4040
NvOnnxParser.cpp
4141
ModelImporter.cpp
42-
builtin_op_importers.cpp
43-
builtin_op_static_checkers.cpp
42+
ModelRefitter.cpp
43+
onnxOpImporters.cpp
4444
ImporterContext.cpp
45-
onnx2trt_utils.cpp
45+
importerUtils.cpp
4646
ShapedWeights.cpp
4747
ShapeTensor.cpp
4848
LoopHelpers.cpp
@@ -51,6 +51,11 @@ set(IMPORTER_SOURCES
5151
onnxErrorRecorder.cpp
5252
ConditionalHelpers.cpp
5353
bfloat16.cpp
54+
onnxOpCheckers.cpp
55+
onnxProtoUtils.cpp
56+
weightUtils.cpp
57+
WeightsContext.cpp
58+
TensorOrWeights.cpp
5459
)
5560

5661
if (BUILD_ONNXIFI)

ConditionalHelpers.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "ConditionalHelpers.hpp"
66
#include "ModelImporter.hpp"
7-
#include "onnx2trt_utils.hpp"
7+
#include "importerUtils.hpp"
88
#include "toposort.hpp"
99

1010
namespace onnx2trt
@@ -34,7 +34,7 @@ SubgraphPortsMap::const_iterator findLayer(const SubgraphPortsMap& inputs, const
3434

3535
// Add an ConditionalInputLayer between `layer` and its inputs.
3636
// I.e. input[inIdx] -> layer ==> input[inIdx] -> ConditionalInputLayer -> layer.
37-
Status addConditionalInputLayer(IImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
37+
Status addConditionalInputLayer(ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
3838
nvinfer1::ILayer& layer, int32_t inIdx)
3939
{
4040
auto input = layer.getInput(inIdx);
@@ -54,27 +54,28 @@ Status addConditionalInputLayer(IImporterContext* ctx, nvinfer1::IIfConditional*
5454
nvinfer1::IIfConditionalInputLayer* inputLayer = nullptr;
5555
if (it == inputsMap.end())
5656
{
57-
inputLayer = conditional->addInput(*input);
57+
inputLayer = N_CHECK(conditional->addInput(*input));
5858
inputsMap[name] = inputLayer;
5959
const std::string inputLayerName(name);
6060
ctx->registerLayer(inputLayer, inputLayerName + "_InputLayer", nullptr);
6161
// Note: Since multiple conditionals may use the same external tensor, check unique names for output tensors of
6262
// IfConditionalInputLayers to avoid tensor name duplication.
6363
ctx->registerTensor(
64-
TensorOrWeights{inputLayer->getOutput(0)}, inputLayerName + "_InputLayer_output", /*checkUniqueName*/ true);
64+
TensorOrWeights{N_CHECK(inputLayer->getOutput(0))}, inputLayerName + "_InputLayer_output", /*checkUniqueName*/ true);
6565
}
6666
else
6767
{
6868
// An InputLayer may in the inputsMap if it has several consumers.
6969
inputLayer = it->second;
7070
}
71-
layer.setInput(inIdx, *(inputLayer->getOutput(0)));
71+
auto ifOutput = N_CHECK(inputLayer->getOutput(0));
72+
layer.setInput(inIdx, *ifOutput);
7273
return Status::success();
7374
};
7475

7576
// Take a snapshot of the network before and after parsing the subgraph and return a list
7677
// of newly added network layers.
77-
Status importSubgraph(IImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const& subgraph,
78+
Status importSubgraph(ImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const& subgraph,
7879
std::vector<nvinfer1::ILayer*>& newLayers, std::vector<TensorOrWeights>& subgraphTensors)
7980
{
8081
auto net = ctx->network();
@@ -84,7 +85,7 @@ Status importSubgraph(IImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const&
8485
NameScope nameScope(*ctx);
8586

8687
std::vector<Status> errors{};
87-
CHECK(onnx2trt::parseGraph(ctx, subgraph, errors));
88+
CHECK_STATUS(onnx2trt::parseGraph(ctx, subgraph, errors));
8889

8990
for (int32_t i = 0; i < subgraph.output_size(); ++i)
9091
{
@@ -101,7 +102,7 @@ Status importSubgraph(IImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const&
101102
}
102103

103104
// Add an IConditionalInputLayer to `layer`'s inputs, if they don't already exist.
104-
Status addConditionalInputIfNeeded(IImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
105+
Status addConditionalInputIfNeeded(ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
105106
nvinfer1::ILayer& layer, SubgraphPortsMap subgraphInputsMap)
106107
{
107108
// Return all of the layer's inputs that are external to the subgraph that
@@ -128,7 +129,7 @@ Status addConditionalInputIfNeeded(IImporterContext* ctx, nvinfer1::IIfCondition
128129
}
129130

130131
// Add IConditionalInputLayers to `layer`'s inputs.
131-
Status addIfInputLayers(IImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
132+
Status addIfInputLayers(ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
132133
const std::vector<nvinfer1::ILayer*>& newLayers)
133134
{
134135
// Find all of the tensors entering the subgraph.

ConditionalHelpers.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ Status getSubgraphOutputs(const std::vector<nvinfer1::ILayer*>& newLayers,
3333

3434
// Take a snapshot of the network before and after parsing the subgraph and return a list
3535
// of newly added network layers.
36-
Status importSubgraph(IImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const& subgraph,
36+
Status importSubgraph(ImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const& subgraph,
3737
std::vector<nvinfer1::ILayer*>& newLayers, std::vector<TensorOrWeights>& subgraphTensors);
3838

3939
using InputsMap = std::unordered_map<std::string, nvinfer1::IIfConditionalInputLayer*>;
4040

4141
// Add IIfConditionalInputLayers to the inputs of the subgraph indicated by `subgraph`.
42-
onnx2trt::Status addIfInputLayers(IImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
42+
onnx2trt::Status addIfInputLayers(ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
4343
const std::vector<nvinfer1::ILayer*>& newLayers);
4444

4545
} // namespace onnx2trt

ImporterContext.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "ImporterContext.hpp"
66
#include "NvInferVersion.h"
7+
#include "importerUtils.hpp"
8+
#include "weightUtils.hpp"
79
#include <sstream>
810

911
#if !defined(_WIN32)
@@ -52,7 +54,7 @@ void ImporterContext::popBaseNameScope()
5254
void ImporterContext::registerTensor(TensorOrWeights tensor, std::string const& basename, bool const checkUniqueName)
5355
{
5456
// TRT requires unique tensor names.
55-
std::string const& uniqueName = generateUniqueName(mTensorNames, basename);
57+
std::string const& uniqueName = generateUniqueName(mTensorNames, mSuffixCounter, basename);
5658

5759
if (tensor)
5860
{
@@ -109,7 +111,7 @@ void ImporterContext::registerLayer(nvinfer1::ILayer* layer, std::string const&
109111
if (layer)
110112
{
111113
std::string const name = basename.empty() ? layer->getName() : basename;
112-
std::string const& uniqueName = generateUniqueName(mLayerNames, name);
114+
std::string const& uniqueName = generateUniqueName(mLayerNames, mSuffixCounter, basename);
113115

114116
auto* ctx = this; // To enable logging.
115117
if (node != nullptr)
@@ -132,7 +134,7 @@ void ImporterContext::registerLayer(nvinfer1::ILayer* layer, std::string const&
132134
mConstantLayers.insert({uniqueName, static_cast<nvinfer1::IConstantLayer*>(layer)});
133135
}
134136
}
135-
if (node != nullptr)
137+
if (node != nullptr && layer != nullptr)
136138
{
137139
processMetadata(this, *node, layer);
138140
}
@@ -154,7 +156,7 @@ std::string getOSLibraryName(char const* logicalName)
154156
#if defined(_WIN32)
155157
libName << logicalName << ".dll";
156158
#else
157-
libName << "lib" << logicalName << ".so." << NV_TENSORRT_SONAME_MAJOR;
159+
libName << "lib" << logicalName << ".so." << NV_TENSORRT_MAJOR;
158160
#endif
159161
return libName.str();
160162
}

0 commit comments

Comments
 (0)