rfcs
rfcs copied to clipboard
RFC-0010: TensorRef
This proposal introduces a new class TensorRef, to replace all
places in our codebase where we currently use const Tensor&. The
distinguishing characteristics of this class are:
- It is non-owning
- It is as safe as other by-value reference types (like
c10::ArrayReforstd::string_view) - It is implicitly convertible (with some exceptions) to
const Tensor&(i.e., it can be introduced incrementally)
Signed-off-by: Edward Z. Yang [email protected]
A variation of this has been implemented in https://github.com/pytorch/pytorch/pull/55685
A variation of this has been implemented in pytorch/pytorch#55685
As with the TensorRef in the proposal, MaybeOwned is hobbled by the Itanium ABI requirement to pass it by reference always, so it doesn't solve the argument passing problem either.