Skip to content

Commit

Permalink
TensorRT 10.5 GA Release - 2024-10-01 (#998)
Browse files Browse the repository at this point in the history
* Staging 10.5 release

Signed-off-by: Michal Guzek <mguzek@nvidia.com>

* Update minor version in CMakeLists

Signed-off-by: Michal Guzek <mguzek@nvidia.com>

---------

Signed-off-by: Michal Guzek <mguzek@nvidia.com>
  • Loading branch information
moraxu authored Oct 8, 2024
1 parent 3775e49 commit 886aff9
Show file tree
Hide file tree
Showing 18 changed files with 1,208 additions and 1,012 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ add_definitions("-DSOURCE_LENGTH=${SOURCE_LENGTH}")
# Version information
#--------------------------------------------------
set(ONNX2TRT_MAJOR 10)
set(ONNX2TRT_MINOR 4)
set(ONNX2TRT_MINOR 5)
set(ONNX2TRT_PATCH 0)
set(ONNX2TRT_VERSION "${ONNX2TRT_MAJOR}.${ONNX2TRT_MINOR}.${ONNX2TRT_PATCH}" CACHE STRING "ONNX2TRT version")

Expand Down
31 changes: 12 additions & 19 deletions ConditionalHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ SubgraphPortsMap::const_iterator findLayer(const SubgraphPortsMap& inputs, const

// Add an ConditionalInputLayer between `layer` and its inputs.
// I.e. input[inIdx] -> layer ==> input[inIdx] -> ConditionalInputLayer -> layer.
Status addConditionalInputLayer(ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
void addConditionalInputLayer(ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
nvinfer1::ILayer& layer, int32_t inIdx)
{
auto input = layer.getInput(inIdx);
if (input == nullptr)
{
// Phantom input (an input that is really constant weights).
return Status::success();
return;
}

if (layer.getType() == nvinfer1::LayerType::kCONDITIONAL_OUTPUT)
{
return Status::success();
return;
}

auto const name = input->getName();
Expand All @@ -70,12 +70,11 @@ Status addConditionalInputLayer(ImporterContext* ctx, nvinfer1::IIfConditional*
}
auto ifOutput = N_CHECK(inputLayer->getOutput(0));
layer.setInput(inIdx, *ifOutput);
return Status::success();
};

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

std::vector<Status> errors{};
CHECK_STATUS(onnx2trt::parseGraph(ctx, subgraph, errors));
onnx2trt::parseGraph(ctx, subgraph, errors);

for (int32_t i = 0; i < subgraph.output_size(); ++i)
{
Expand All @@ -97,12 +96,10 @@ Status importSubgraph(ImporterContext* ctx, ::ONNX_NAMESPACE::GraphProto const&
{
newLayers.push_back(net->getLayer(i));
}

return Status::success();
}

// Add an IConditionalInputLayer to `layer`'s inputs, if they don't already exist.
Status addConditionalInputIfNeeded(ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
void addConditionalInputIfNeeded(ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
nvinfer1::ILayer& layer, SubgraphPortsMap subgraphInputsMap)
{
// Return all of the layer's inputs that are external to the subgraph that
Expand All @@ -125,11 +122,10 @@ Status addConditionalInputIfNeeded(ImporterContext* ctx, nvinfer1::IIfConditiona
LOG_VERBOSE("Adding Input layer for " << layer.getName());
addConditionalInputLayer(ctx, conditional, inputsMap, layer, inIdx);
}
return Status::success();
}

// Add IConditionalInputLayers to `layer`'s inputs.
Status addIfInputLayers(ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
void addIfInputLayers(ImporterContext* ctx, nvinfer1::IIfConditional* conditional, InputsMap& inputsMap,
const std::vector<nvinfer1::ILayer*>& newLayers)
{
// Find all of the tensors entering the subgraph.
Expand All @@ -143,12 +139,10 @@ Status addIfInputLayers(ImporterContext* ctx, nvinfer1::IIfConditional* conditio
{
addConditionalInputIfNeeded(ctx, conditional, inputsMap, *layer, subgraphInputsMap);
}

return Status::success();
}

// Given a subgraph, find all of its external inputs/outputs (tensors entering/exiting the subgraph).
Status getSubgraphTensors(const std::vector<nvinfer1::ILayer*>& newLayers,
void getSubgraphTensors(const std::vector<nvinfer1::ILayer*>& newLayers,
std::unordered_map<nvinfer1::ITensor*, std::set<int32_t>>& externalOutputs, bool extractOutputs,
const std::vector<std::string>* reportedOutputs = nullptr)
{
Expand Down Expand Up @@ -255,20 +249,19 @@ Status getSubgraphTensors(const std::vector<nvinfer1::ILayer*>& newLayers,
externalOutputs[tensor].insert(portIndex);
}
}
return Status::success();
}

Status getSubgraphOutputs(const std::vector<nvinfer1::ILayer*>& newLayers,
void getSubgraphOutputs(const std::vector<nvinfer1::ILayer*>& newLayers,
std::unordered_map<nvinfer1::ITensor*, std::set<int32_t>>& externalOutputs,
const std::vector<std::string>& reportedOutputs)
{
return getSubgraphTensors(newLayers, externalOutputs, true, &reportedOutputs);
getSubgraphTensors(newLayers, externalOutputs, true, &reportedOutputs);
}

Status getSubgraphInputs(const std::vector<nvinfer1::ILayer*>& newLayers,
void getSubgraphInputs(const std::vector<nvinfer1::ILayer*>& newLayers,
std::unordered_map<nvinfer1::ITensor*, std::set<int32_t>>& externalInputs)
{
return getSubgraphTensors(newLayers, externalInputs, false);
getSubgraphTensors(newLayers, externalInputs, false);
}

} // namespace onnx2trt
8 changes: 4 additions & 4 deletions ConditionalHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ namespace onnx2trt
// Given a subgraph, find all of its external inputs (tensors entering the subgraph).
// The result is returned in `subgraphInputs`, which is a map indexed by ITensor (a tensor entering the subgraph) and
// with values indicating a set of external input indices.
Status getSubgraphInputs(std::vector<nvinfer1::ILayer*> const& newLayers,
void getSubgraphInputs(std::vector<nvinfer1::ILayer*> const& newLayers,
std::unordered_map<nvinfer1::ITensor*, std::set<int32_t>>& subgraphInputs);

// Given a subgraph, find all of its external outputs (tensors exiting the subgraph).
// The result is returned in `subgraphInputs`, which is a map indexed by ITensor (a tensor exiting the subgraph) and
// with values indicating a set of external outputs indices.
Status getSubgraphOutputs(const std::vector<nvinfer1::ILayer*>& newLayers,
void getSubgraphOutputs(const std::vector<nvinfer1::ILayer*>& newLayers,
std::unordered_map<nvinfer1::ITensor*, std::set<int32_t>>& subgraphOutputs,
const std::vector<std::string>& reportedOutputs);

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

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

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

} // namespace onnx2trt
6 changes: 3 additions & 3 deletions ImporterContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ class ImporterContext
}
};

typedef ValueOrStatus<std::vector<TensorOrWeights>> NodeImportResult;
typedef std::function<NodeImportResult(ImporterContext* ctx, ::ONNX_NAMESPACE::NodeProto const& node,
size_t const nodeIdx, std::vector<TensorOrWeights>& inputs)>
typedef std::vector<TensorOrWeights> NodeOutputs;
typedef std::function<NodeOutputs(ImporterContext* ctx, ::ONNX_NAMESPACE::NodeProto const& node, size_t const nodeIdx,
std::vector<TensorOrWeights>& inputs)>
NodeImporter;

typedef std::function<void(
Expand Down
Loading

0 comments on commit 886aff9

Please sign in to comment.