Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for tt.bitcast on tensor of pointers #235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nullkooland
Copy link
Contributor

  1. In TritonToStructured, move tt.bitcast on tensor of pointers to the source scalar pointer tracked by PtrAnalysis, for instance:
%6 = tt.splat %arg0: !tt.ptr<i1> -> tensor<512x!tt.ptr<i1>>
%7 = tt.addptr %6, %offsets : tensor<512x!tt.ptr<i1>>, tensor<512xi32>
%8 = tt.bitcast %7 : tensor<512x!tt.ptr<i1>> -> tensor<512x!tt.ptr<i8>>

to

 %3 = tt.bitcast %arg0 : !tt.ptr<i1> -> !tt.ptr<i8>
 %4 = tts.make_tptr %3 to sizes: [512], strides: [1], offsets: [%offsets], shape: [0], order: [] : <i8> to tensor<512x!tt.ptr<i8>>
  1. In TritonToUnstructured, Allow tt.bitcast op in ptr sequence.
  2. In TritonPtrToMemref, convert tt.bitcast op on ptr to builtin.unrealized_conversion_cast op on unranked memref, since currently memref dialect does not have a suitable op for "pointer reinterpret cast" semantics.

The whole thing is kind of hacky, maybe we can wait for upstream ptr dialect is fully landed, and rework on the whole pointer bitcast lowering.

@Nullkooland
Copy link
Contributor Author

Related PR #171 @parsifal-47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant