slyubomirsky opened a new pull request, #15372:
URL: https://github.com/apache/tvm/pull/15372

   As the first step in proposal #15319, this PR adds a `call_tir_inplace` 
operator that is responsible for invoking `PrimFunc`s that perform in-place 
changes. Namely, this means that the `PrimFunc`s directly mutate an input and 
do not expect a freshly allocated output tensor like in a typical DPS style 
`call_tir` invocation.
   
   `call_tir_inplace` has the same signature as `call_tir`, except with one 
additional argument: `inplace_indices`, which is a list of argument indices. 
Suppose there are `N` tensor arguments to `call_tir_inplace`. Then 
`inplace_indices` has the following property:
   1. If `inplace_indices[i] = j`, where `0 <= j < N`, then the `i`th output of 
the call will alias the `j`th argument. I.e., the `j`th argument is expected to 
be mutated inplace.
   2. If `inplace_indices[i] = -1`, then the `i`th output of the call will be a 
freshly allocated tensor. The `PrimFunc` will thus expect a newly allocated 
tensor corresponding to that output in the usual DPS style.
   
   Note that `call_tir_inplace` is treated as pure by the type system even 
though it is not, in fact, pure. This means that it is dangerous to call this 
operator directly! It is provided right now for testing purposes; in the future 
(per proposal #15319), these calls will be inserted only by passes that first 
verify that it is _safe_ to perform ops in-place. (We could discuss the phase 
ordering here; perhaps it will make more sense to simply perform the in-place 
lowering late in compilation, after getting rid of dataflow blocks.)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to