python.builtin
dynamic_shape_round
Original source code:
# mypy: allow-untyped-defs
import
Original source code:
# mypy: allow-untyped-defs
import
Result:
RuntimeError: Constraints violated (dim0_x)! For more information, run with TORCH_LOGS="+dynamic".Original source code:
# mypy: allow-untyped-defs
import torch
class TensorSetattr(torch.nn.Module):
"""
setattr() call onto tensors is not supported.
"""
def forward(self, x, attr):
setattr(x, attr, torch.randn(3, 2))
return x + 4
example_args = (torch.randn(3, 2), "attr")
tags = {"python.builtin"}
model = TensorSetattr()
torch.export.export(model, example_args)
Result:
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, x: "f32[3, 2]", attr):
randn: "f32[3, 2]" = torch.ops.aten.randn.default([
Original source code:
# mypy: allow-untyped-defs
import torch
class A:
@classmethod
def func(cls, x):
return 1 + x
class TypeReflectionMethod(torch.nn.Module):
"""
type() calls on custom objects followed by attribute accesses are not allowed
due to its overly dynamic nature.
"""
def forward(self, x):
a = A()
return type(a).func(x)
example_args = (torch.randn(3, 4),)
tags = {"python.builtin"}
model = TypeReflectionMethod()
torch.export.export(model, example_args)
Result:
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, x: "f32[3, 4]"):
add: "f32[3, 4]" = torch.ops.aten.add.Tensor(x,