add native view_copy.out ops, teach codegen about tensorlist out=

Pull Request resolved: https://github.com/pytorch/pytorch/pull/76126

Approved by: https://github.com/ezyang
This commit is contained in:
Brian Hirsh
2022-05-17 20:09:44 -07:00
committed by PyTorch MergeBot
parent a325fa94b9
commit edc904d6ba
5 changed files with 491 additions and 5 deletions

View File

@ -201,7 +201,10 @@ def returntype_type(t: Type, *, mutable: bool) -> CType:
elif t.name == BaseTy.Scalar:
return BaseCType(scalarT)
elif isinstance(t, ListType):
elem = returntype_type(t.elem, mutable=mutable)
assert (
not mutable
), "Native functions should never return a mutable tensor list. They should return void."
elem = returntype_type(t.elem, mutable=False)
assert t.size is None, f"fixed size list returns not supported: {t}"
return VectorCType(elem)