mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[dynamo] Use polyfill to implement comparison operators (#144485)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144485 Approved by: https://github.com/jansel
This commit is contained in:
committed by
PyTorch MergeBot
parent
3e135993bd
commit
d1f82de2bf
@ -15,6 +15,7 @@ from ..bytecode_transformation import create_call_function, create_instruction
|
||||
from ..exc import raise_observed_exception, unimplemented
|
||||
from ..source import AttrSource
|
||||
from ..utils import (
|
||||
cmp_name_to_op_mapping,
|
||||
get_fake_value,
|
||||
guard_if_dyn,
|
||||
istype,
|
||||
@ -136,6 +137,18 @@ class BaseListVariable(VariableTracker):
|
||||
[self] + list(args),
|
||||
kwargs,
|
||||
)
|
||||
elif name in cmp_name_to_op_mapping:
|
||||
left = self
|
||||
right = args[0]
|
||||
if not isinstance(left, BaseListVariable) and not isinstance(
|
||||
right, BaseListVariable
|
||||
):
|
||||
return variables.ConstantVariable.create(NotImplemented)
|
||||
return variables.UserFunctionVariable(polyfills.list_cmp).call_function(
|
||||
tx,
|
||||
[variables.BuiltinVariable(cmp_name_to_op_mapping[name]), left, right],
|
||||
{},
|
||||
)
|
||||
|
||||
return super().call_method(tx, name, args, kwargs)
|
||||
|
||||
|
Reference in New Issue
Block a user