From e04065c883662467e4aaa7a0450d9f3d299bec07 Mon Sep 17 00:00:00 2001 From: Jeff Daily Date: Mon, 25 Mar 2024 19:21:24 +0000 Subject: [PATCH] work-around upstream pytorch changing fromDLPack to take non-const pointer --- .../torch_cpp_extensions/aten_op_executor/aten_op_executor.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/onnxruntime/python/torch_cpp_extensions/aten_op_executor/aten_op_executor.cc b/onnxruntime/python/torch_cpp_extensions/aten_op_executor/aten_op_executor.cc index 903a394a06ef3..a92f14fade86f 100644 --- a/onnxruntime/python/torch_cpp_extensions/aten_op_executor/aten_op_executor.cc +++ b/onnxruntime/python/torch_cpp_extensions/aten_op_executor/aten_op_executor.cc @@ -52,7 +52,8 @@ struct ATenOperator { c10::IValue i_value; // Create the torch tensor from this DLPack no matter we need it or not below, // so that the dlpack's deleter will be triggered when torch tensor is out of scope. - at::Tensor tensor = at::fromDLPack(dlpack); + // work-around upstream pytorch changing fromDLPack to take non-const pointer + at::Tensor tensor = at::fromDLPack(const_cast(dlpack)); switch (elem_kinds[index]) { case c10::TypeKind::TensorType: { i_value = is_optional ? c10::IValue(c10::optional(tensor)) : c10::IValue(tensor);