Skip to content

Commit 6fe0206

Browse files
authored
Add const cast for DLManagedTensor (#19982)
### Description <!-- Describe your changes. --> Add Const Cast for DLManagedTensor as PyTorch has changed it's [code](pytorch/pytorch#121102) which creates incompatibility. ### 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. --> Fix the below error while configuring ORT-training with nightly PyTorch ``` aten_op_executor.cc:60:40: error: invalid conversion from ‘const DLManagedTensor*’ to ‘DLManagedTensor*’ [-fpermissive] 60 | at::Tensor tensor = at::fromDLPack(dlpack); | ^~~~~~ | | | const DLManagedTensor* ```
1 parent c45cff6 commit 6fe0206

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

onnxruntime/python/torch_cpp_extensions/aten_op_executor/aten_op_executor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct ATenOperator {
5757
c10::IValue i_value;
5858
// Create the torch tensor from this DLPack no matter we need it or not below,
5959
// so that the dlpack's deleter will be triggered when torch tensor is out of scope.
60-
at::Tensor tensor = at::fromDLPack(dlpack);
60+
at::Tensor tensor = at::fromDLPack(const_cast<DLManagedTensor*>(dlpack));
6161
switch (elem_kinds[index]) {
6262
case c10::TypeKind::TensorType: {
6363
i_value = is_optional ? c10::IValue(c10::optional<at::Tensor>(tensor)) : c10::IValue(tensor);

0 commit comments

Comments
 (0)