rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

RFC-0010: TensorRef

Open ezyang opened this issue 4 years ago • 2 comments

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:

  1. It is non-owning
  2. It is as safe as other by-value reference types (like c10::ArrayRef or std::string_view)
  3. It is implicitly convertible (with some exceptions) to const Tensor& (i.e., it can be introduced incrementally)

Rendered

Signed-off-by: Edward Z. Yang [email protected]

ezyang avatar Mar 03 '21 20:03 ezyang

A variation of this has been implemented in https://github.com/pytorch/pytorch/pull/55685

ezyang avatar Apr 10 '21 02:04 ezyang

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.

swolchok avatar May 26 '21 22:05 swolchok