diff --git a/onnxruntime/contrib_ops/cuda/transformers/generation_device_helper.cc b/onnxruntime/contrib_ops/cuda/transformers/generation_device_helper.cc index 11dabc4e97..e5e75a65cc 100644 --- a/onnxruntime/contrib_ops/cuda/transformers/generation_device_helper.cc +++ b/onnxruntime/contrib_ops/cuda/transformers/generation_device_helper.cc @@ -99,7 +99,7 @@ Status AddToFeeds(const IExecutionProvider* execution_provider, size_t total_bytes = 0; for (auto& input : inputs) { if (input.IsAllocated()) { - total_bytes += input.Get().Shape().Size() * input.Type()->Size(); + total_bytes += input.Get().SizeInBytes(); } } @@ -115,7 +115,7 @@ Status AddToFeeds(const IExecutionProvider* execution_provider, for (auto& input : inputs) { if (input.IsAllocated()) { const Tensor& tensor = input.Get(); - const size_t bytes = input.Type()->Size() * tensor.Shape().Size(); + const size_t bytes = tensor.SizeInBytes(); MLDataType dataType = tensor.DataType(); if (dataType == DataTypeImpl::GetType()) { memcpy(destination, input.Get().Data(), bytes); @@ -152,7 +152,7 @@ Status AddToFeeds(const IExecutionProvider* execution_provider, if (input.IsAllocated()) { const Tensor& tensor = input.Get(); const TensorShape& shape = tensor.Shape(); - const size_t bytes = input.Type()->Size() * shape.Size(); + const size_t bytes = tensor.SizeInBytes(); MLDataType dataType = tensor.DataType(); OrtValue device_input;