tlopex commented on code in PR #18540:
URL: https://github.com/apache/tvm/pull/18540#discussion_r2582483437
##########
python/tvm/relax/frontend/torch/exported_program_translator.py:
##########
@@ -48,6 +48,19 @@ def _convert_pytorch_tensor_to_tvm(tensor_value:
torch.Tensor) -> tvm.runtime.Te
tvm.runtime.Tensor
The converted TVM tensor.
"""
+ # Fix for Issue #18407: Handle FakeTensor and lifted tensors (from
torch.export)
+ # FakeTensor is an internal PyTorch API that may not be available in
all versions
+ try:
+ # Check if it's a FakeTensor from torch._subclasses, which is an
internal API
+ FakeTensor = torch._subclasses.fake_tensor.FakeTensor
+ if isinstance(tensor_value, FakeTensor):
+ # Create a real tensor with the same shape and dtype as a
placeholder
+ real_tensor = torch.zeros(tensor_value.shape,
dtype=tensor_value.dtype)
Review Comment:
I think replace PyTorch FakeTensor/LiftedTensor with a zero-filled tensor
changes program semantics. That's dangerous and can hide real frontend/lowering
bugs. Instead, we should create a proper symbolic placeholder (shape-only)
tensor rather than materializing dummy data.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]