mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[Dynamo] Replace unimplemented
with unimplemented_v2
in torch/_dynamo/variables/lists.py
(#151873)
Part of #147913 Replace `unimplemented` with`unimplemented_v2` in `torch/_dynamo/variables/lists.py` Pull Request resolved: https://github.com/pytorch/pytorch/pull/151873 Approved by: https://github.com/williamwen42 Co-authored-by: William Wen <william.wen42@gmail.com>
This commit is contained in:
committed by
PyTorch MergeBot
parent
0423a7b322
commit
cbcf677223
@ -26,7 +26,7 @@ import torch.fx
|
||||
|
||||
from .. import graph_break_hints, polyfills, variables
|
||||
from ..bytecode_transformation import create_call_function, create_instruction
|
||||
from ..exc import raise_observed_exception, unimplemented, unimplemented_v2
|
||||
from ..exc import raise_observed_exception, unimplemented_v2
|
||||
from ..source import AttrSource
|
||||
from ..utils import (
|
||||
cmp_name_to_op_mapping,
|
||||
@ -137,7 +137,14 @@ class BaseListVariable(VariableTracker):
|
||||
if value.constant is not None and value.constant.numel() == 1:
|
||||
value = variables.ConstantVariable.create(value.constant.item())
|
||||
else:
|
||||
unimplemented("__getitem__ with non-constant tensor")
|
||||
unimplemented_v2(
|
||||
gb_type="Indexing list with non-scalar tensor",
|
||||
context=f"call_method {self} {name} {args} {kwargs}",
|
||||
explanation=(
|
||||
"Attempted to index list-like object with tensor with > 1 element."
|
||||
),
|
||||
hints=[*graph_break_hints.USER_ERROR],
|
||||
)
|
||||
else:
|
||||
value = args[0]
|
||||
return self.getitem_const(tx, value)
|
||||
@ -341,7 +348,13 @@ class RangeVariable(BaseListVariable):
|
||||
def var_getattr(self, tx: "InstructionTranslator", name):
|
||||
fields = ["start", "stop", "step"]
|
||||
if name not in fields:
|
||||
unimplemented(f"range.{name}")
|
||||
unimplemented_v2(
|
||||
gb_type="Unsupported attribute for range() object",
|
||||
context=f"var_getattr {self} {name}",
|
||||
explanation=f"Expected attribute to be one of {','.join(fields)} "
|
||||
f"but got {name}",
|
||||
hints=[*graph_break_hints.USER_ERROR],
|
||||
)
|
||||
return self.items[fields.index(name)]
|
||||
|
||||
|
||||
@ -458,8 +471,11 @@ class ListVariable(CommonListMethodsVariable):
|
||||
tx.output.side_effects.mutation(self)
|
||||
if isinstance(key, SliceVariable):
|
||||
if not value.has_force_unpack_var_sequence(tx):
|
||||
unimplemented(
|
||||
f"Missing dynamo support for expanding {value} into a list for slice assignment."
|
||||
unimplemented_v2(
|
||||
gb_type="Unsupported conversion for slice assignment",
|
||||
context=f"call_method {self} {name} {args}",
|
||||
explanation=f"Missing dynamo support for converting {value} into a list for slice assignment.",
|
||||
hints=[*graph_break_hints.SUPPORTABLE],
|
||||
)
|
||||
self.items[key.as_python_constant()] = value.force_unpack_var_sequence(
|
||||
tx
|
||||
@ -1041,7 +1057,13 @@ class SliceVariable(VariableTracker):
|
||||
return variables.GetAttrVariable(self, name)
|
||||
fields = ["start", "stop", "step"]
|
||||
if name not in fields:
|
||||
unimplemented(f"slice.{name}")
|
||||
unimplemented_v2(
|
||||
gb_type="Unsupported attribute for slice() object",
|
||||
context=f"var_getattr {self} {name}",
|
||||
explanation=f"Expected attribute to be one of {','.join(fields)} "
|
||||
f"but got {name}",
|
||||
hints=[*graph_break_hints.USER_ERROR],
|
||||
)
|
||||
return self.items[fields.index(name)]
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user