mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[list] Implement list.remove
(#156242)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156242 Approved by: https://github.com/Skylion007, https://github.com/zou3519 ghstack dependencies: #153969, #156148
This commit is contained in:
committed by
PyTorch MergeBot
parent
e49acfc5c5
commit
c1d69d5dd5
@ -509,6 +509,13 @@ class CommonListMethodsVariable(BaseListVariable):
|
||||
self.items.reverse()
|
||||
tx.output.side_effects.mutation(self)
|
||||
return ConstantVariable.create(None)
|
||||
elif name == "remove" and self.is_mutable():
|
||||
if len(args) != 1 or kwargs:
|
||||
raise_args_mismatch(tx, name)
|
||||
|
||||
idx = self.call_method(tx, "index", args, kwargs)
|
||||
self.call_method(tx, "pop", [idx], {})
|
||||
return ConstantVariable.create(None)
|
||||
else:
|
||||
return super().call_method(tx, name, args, kwargs)
|
||||
|
||||
|
Reference in New Issue
Block a user