You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make subtensor_insert either use in-place updates or use a lowering to loops directly #5042
The two copies have different workloads, and is not possible to implement these within a single dispatch. In the legacy path, the SplitDispatchFunction would split the two copies to enable GPU execution. Since this pass is on the deprecation path, a different approach is needed to lower to GPU.
Approach 1
If we know that %b_tensor and %c_tensor are mapped to the same underlying buffer, then the first copy becomes unnecessary. We can just do the second copy and lower to GPU
Approach 2
The subtensor_insert operation can be lowered to a single loop nest directly.
#5016 should make either approach possible and handles some of the trickier in-place conditions (like when the operand that is mutated in place is used by a subsequent op that is wanting to see the value prior to mutation) - all you'll need to do is either use flow.tensor.update for contiguous updates (it is now tied by default) or specify which result is tied back to which operand when you define the flow.dispatch.workgroups op (which could contain your scf loops).
Here's an example dispatch workgroups op with a tied result (result 0 is tied to operand 0 and as such the workgroup is able to load/store to %arg0_capture):
and here's an example of how the immutability of tensors is preserved with the in-place operations (here the update is mutating %stream_target in place, but %stream_target is also used by the subsequent dispatch and so a snapshot is taken to preserve the contents first):
Activity
benvanik commentedon Mar 10, 2021
#5016 should make either approach possible and handles some of the trickier in-place conditions (like when the operand that is mutated in place is used by a subsequent op that is wanting to see the value prior to mutation) - all you'll need to do is either use flow.tensor.update for contiguous updates (it is now tied by default) or specify which result is tied back to which operand when you define the flow.dispatch.workgroups op (which could contain your scf loops).
Here's an example dispatch workgroups op with a tied result (result 0 is tied to operand 0 and as such the workgroup is able to load/store to %arg0_capture):
and here's an example of how the immutability of tensors is preserved with the in-place operations (here the update is mutating %stream_target in place, but %stream_target is also used by the subsequent dispatch and so a snapshot is taken to preserve the contents first):
Enable concat, gather and torch_index_select on Linalg on tensors path.
Enable concat, gather and torch_index_select on Linalg on tensors path.
MaheshRavishankar commentedon Mar 11, 2021
@antiagainst the PR for in-place update landed. We should be able to use it for this now.
Enable concat, gather and torch_index_select on Linalg on tensors path.
antiagainst commentedon Mar 11, 2021
Fantastic. I'll be working on this tomorrow.
Enable concat, gather and torch_index_select on Linalg on tensors path.
antiagainst commentedon Mar 15, 2021
#5102 addressed this. Closing now.