mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Update extending.rst (#78707)
Follow-up fix for https://github.com/pytorch/pytorch/pull/78073 : https://github.com/pytorch/pytorch/pull/78073#discussion_r887621219 Pull Request resolved: https://github.com/pytorch/pytorch/pull/78707 Approved by: https://github.com/albanD
This commit is contained in:
@ -643,8 +643,8 @@ implementation more permissive about what operations are allowed::
|
||||
def __torch_function__(cls, func, types, args=(), kwargs=None):
|
||||
if kwargs is None:
|
||||
kwargs = {}
|
||||
args = [a._t if hasattr(a, '_t') else a for a in args]
|
||||
metadatas = tuple(a._metadata for a in args if hasattr(a, '_metadata'))
|
||||
args = [a._t if hasattr(a, '_t') else a for a in args]
|
||||
assert len(metadatas) > 0
|
||||
ret = func(*args, **kwargs)
|
||||
return MetadataTensor(ret, metadata=metadatas[0])
|
||||
|
Reference in New Issue
Block a user