From ecc2566719758542ca5d3aaadd82eb514b9340fd Mon Sep 17 00:00:00 2001 From: Chi Lo Date: Sat, 4 Nov 2023 04:13:39 +0000 Subject: [PATCH] update --- .../tensorrt/tensorrt_execution_provider.cc | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc index ed70ba17bdda3..57e497dd6f730 100644 --- a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc +++ b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc @@ -365,46 +365,6 @@ std::unique_lock TensorrtExecutionProvider::GetApiLock() const { return std::unique_lock(singleton); } -Status GetShapeOfShapeTensor(Ort::ConstValue& input_tensor, - std::vector& shape_values, - nvinfer1::ICudaEngine* trt_engine, - int binding_index, - cudaStream_t stream) { - auto tensor_info = input_tensor.GetTensorTypeAndShapeInfo(); - const auto tensor_shapes = tensor_info.GetShape(); - const auto tensor_type = tensor_info.GetElementType(); - nvinfer1::Dims dims = trt_engine->getBindingDimensions(static_cast(binding_index)); - int nb_dims = dims.nbDims; - int shape_size = nb_dims == 0 ? 1 : static_cast(tensor_shapes[0]); // The shape of the "shape tensor" is either zero dimension (scalar) or 1-dimension - shape_values.resize(shape_size, 1); - - switch (tensor_type) { - case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32: { - auto input = std::make_unique(shape_size); - CUDA_RETURN_IF_ERROR(cudaMemcpyAsync(input.get(), input_tensor.GetTensorData(), shape_size * sizeof(int32_t), cudaMemcpyDeviceToHost, stream)); - CUDA_RETURN_IF_ERROR(cudaStreamSynchronize(stream)); - for (int j = 0; j < shape_size; ++j) { - shape_values[j] = input[j]; - } - break; - } - case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64: { - auto input = std::make_unique(shape_size); - CUDA_RETURN_IF_ERROR(cudaMemcpyAsync(input.get(), input_tensor.GetTensorData(), shape_size * sizeof(int64_t), cudaMemcpyDeviceToHost, stream)); - CUDA_RETURN_IF_ERROR(cudaStreamSynchronize(stream)); - for (int j = 0; j < shape_size; ++j) { - shape_values[j] = static_cast(input[j]); - } - break; - } - default: { - return ORT_MAKE_STATUS(ONNXRUNTIME, EP_FAIL, - "TensorRT shape tensor data type: " + std::to_string(tensor_type) + " not supported."); - } - } - return Status::OK(); -} - /* * Get the shape of "shape tensor" input */