diff --git a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc index b89adf20c8..e70105afa4 100644 --- a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc +++ b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc @@ -695,9 +695,7 @@ common::Status TensorrtExecutionProvider::Compile(const std::vectorgetNbInputs(); i < end; ++i) { auto input = trt_network->getInput(i); nvinfer1::Dims dims = input->getDimensions(); - nvinfer1::Dims dims_min = dims; - nvinfer1::Dims dims_opt = dims; - nvinfer1::Dims dims_max = dims; + nvinfer1::Dims dims_min(dims), dims_opt(dims), dims_max(dims); int nb_dims = dims.nbDims; if (input->isShapeTensor()) { // Shape tensor @@ -851,16 +849,14 @@ common::Status TensorrtExecutionProvider::Compile(const std::vectorbuilder; nvinfer1::IOptimizationProfile* trt_profile = nullptr; for (int i = 0, end = num_binding_inputs; i < end; ++i) { - // TODO: check if getInput indexing is same with binding index - auto input = trt_state->network->getInput(i); - nvinfer1::Dims dims = input->getDimensions(); - nvinfer1::Dims dims_min = dims; - nvinfer1::Dims dims_opt = dims; - nvinfer1::Dims dims_max = dims; - // Check and update shape ranges for dynamic shape inputs auto& shape_ranges = trt_state->input_shape_ranges; if (shape_ranges.find(i) != shape_ranges.end()) { + // TODO: check if getInput indexing is same with binding index + auto input = trt_state->network->getInput(i); + nvinfer1::Dims dims = input->getDimensions(); + nvinfer1::Dims dims_min(dims), dims_opt(dims), dims_max(dims); + const OrtValue* input_tensor = ort.KernelContext_GetInput(context, input_indexes[i]); auto tensor_info = ort.GetTensorTypeAndShape(input_tensor); const auto& tensor_shape = ort.GetTensorShape(tensor_info); @@ -870,10 +866,15 @@ common::Status TensorrtExecutionProvider::Compile(const std::vector