Skip to content

Commit

Permalink
Add const cast for DLManagedTensor (#19982)
Browse files Browse the repository at this point in the history
### 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*
```
  • Loading branch information
ajindal1 authored Mar 20, 2024
1 parent c45cff6 commit 6fe0206
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ 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);
at::Tensor tensor = at::fromDLPack(const_cast<DLManagedTensor*>(dlpack));
switch (elem_kinds[index]) {
case c10::TypeKind::TensorType: {
i_value = is_optional ? c10::IValue(c10::optional<at::Tensor>(tensor)) : c10::IValue(tensor);
Expand Down

0 comments on commit 6fe0206

Please sign in to comment.