mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
fix buffer overuse in addtofeed() (#13733)
### Description <!-- Describe your changes. --> ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
This commit is contained in:
parent
e306b44e98
commit
c1bda4c1cc
1 changed files with 3 additions and 3 deletions
|
|
@ -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<Tensor>().Shape().Size() * input.Type()->Size();
|
||||
total_bytes += input.Get<Tensor>().SizeInBytes();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ Status AddToFeeds(const IExecutionProvider* execution_provider,
|
|||
for (auto& input : inputs) {
|
||||
if (input.IsAllocated()) {
|
||||
const Tensor& tensor = input.Get<Tensor>();
|
||||
const size_t bytes = input.Type()->Size() * tensor.Shape().Size();
|
||||
const size_t bytes = tensor.SizeInBytes();
|
||||
MLDataType dataType = tensor.DataType();
|
||||
if (dataType == DataTypeImpl::GetType<int32_t>()) {
|
||||
memcpy(destination, input.Get<Tensor>().Data<int32_t>(), bytes);
|
||||
|
|
@ -152,7 +152,7 @@ Status AddToFeeds(const IExecutionProvider* execution_provider,
|
|||
if (input.IsAllocated()) {
|
||||
const Tensor& tensor = input.Get<Tensor>();
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue