mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Fixed creation of ORT_Value to pass offset of 0 (#11004)
This commit is contained in:
parent
47c09e6701
commit
cb31b7eab1
2 changed files with 7 additions and 1 deletions
|
|
@ -133,7 +133,7 @@ OrtValue create_ort_value(
|
|||
|
||||
OrtValue ort_tensor;
|
||||
onnxruntime::Tensor::InitOrtValue(element_type, onnxruntime::TensorShape(tensor.sizes().vec()), tensor.data_ptr(),
|
||||
*mem_info, ort_tensor, tensor.storage_offset() * element_type->Size(),
|
||||
*mem_info, ort_tensor, 0L /* offset = 0 - because tensor.data_ptr() includes the underyling offset */,
|
||||
tensor.strides().vec());
|
||||
return ort_tensor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,5 +114,11 @@ class OrtOpTests(unittest.TestCase):
|
|||
x = cpu_tensor.min()
|
||||
assert torch.allclose(x, y.cpu())
|
||||
|
||||
def test_narrow(self):
|
||||
cpu_tensor = torch.rand(10, 10)
|
||||
cpu_narrow = cpu_tensor.narrow(0, 5, 5)
|
||||
ort_narrow = cpu_narrow.to('ort')
|
||||
assert torch.allclose(cpu_narrow, ort_narrow.cpu())
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Reference in a new issue