[Performance] OrtValue created form OrtValue.ortvalue_from_numpy() has the same ptr same as the previous one, it cause the value of the previous variable to be modified.
Describe the issue
Hi, I use onnxruntime with IOBinding on python, our model has 7 inputs. when I use the OrtValue.ortvalue_from_numpy() to create the OrtValue, I find that the OrtValue.ptr() of the variable is the same as the previous one, it cause the value of the variable at the front to be modified, resulting in incorrect inference results. How can I solve this problem? Thank you
To reproduce
I use the code to create OrtValue:
for i in range(len(input_names)):
if isinstance(model_input[i], np.ndarray):
value = onnxruntime.OrtValue.ortvalue_from_numpy(model_input[i], 'cuda', 0)
dtype = model_input[i].dtype
shape = model_input[i].shape
self.binding.bind_input(
name=input_names[i],
device_type='cuda',
device_id=0,
element_type=dtype,
shape=value.shape(),
buffer_ptr=value.data_ptr()
)
print(f'inputname: {input_names[i]}')
print(f'value_prt: {value.data_ptr()}')
print(f'value_shape: {value.shape()}')
print(f'value: {value}')
As shown above, the value of langid will be changed to the value of acoustic_postion_end
Urgency
No response
Platform
Linux
OS Version
4.18.0
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.18.0
ONNX Runtime API
Python
Architecture
X64
Execution Provider
CUDA
Execution Provider Library Version
CUDA 12.1
Model File
No response
Is this a quantized model?
No
This is a feature that creates OrtValue on top of the given buffer and avoids copying tensors that tend to be huge. The gain is in perf and memory consumption.
This is a feature that creates OrtValue on top of the given buffer and avoids copying tensors that tend to be huge. The gain is in perf and memory consumption.
How can I avoid the current Ortvalue from using the previous Ortvalue's memory and changing it’s value?
This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.
This issue has been automatically closed as 'not planned' because it has been marked as 'stale' for more than 30 days without activity. If you believe this is still an issue, please feel free to reopen it.
This issue has been automatically closed as 'not planned' because it has been marked as 'stale' for more than 30 days without activity. If you believe this is still an issue, please feel free to reopen it.