TensorComprehensions icon indicating copy to clipboard operation
TensorComprehensions copied to clipboard

Handle temporaries

Open prigoyal opened this issue 7 years ago • 1 comments

right now, everything is either an input or output. Reason being TC does not do any allocation by itself. We should find a better way to handle this

cc Albert Cohen who is interested in this

prigoyal avatar Feb 15 '18 13:02 prigoyal

We had discussions about this with @Yangqing, @zdevito and others that it would be easy to:

  1. split into inputs, outputs, temporaries
  2. pass a alloc and a free lambda operating on DLTensors that should a. convert back to a particular framework X tensor type of choice form DLPack b. alloc the tmp automatically using inferred sizes, it is the responsibility of framework X to ensure that alloc/free have decent perf (e.g use a view in a preallocated buffer) c. free the tmp once the call to run exits.
  3. this will help to automatically infer the positional arguments gradInput form output and let tensors that live in tmp be just the tensors that are written to and that are not declared as output.

nicolasvasilache avatar Feb 16 '18 06:02 nicolasvasilache