-
Notifications
You must be signed in to change notification settings - Fork 283
WIP: support specialization constant sized array #6871
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
base: master
Are you sure you want to change the base?
Conversation
My thinking is that we should lower such array as a sized array. Why is that not possible?
|
The size of the array should be folded into a The |
It's not impossible. I made this choice is because by lower to unsized array could potentially avoid any potential checks during type checking and IR legalization pass, so that could make this PR simpler, while the two decisions (unsized array vs sized array) should be equally feasible. But maybe I'm overthinking about the cost. |
I don't think there are any checks after IR lowering, and we should be fine there. |
OK, I can change it to sized array, it should be very small change. But the problem still exists, take this example in the description
we want to emit this to something like this:
our currently emit logic won't let me do that. So I guess I will have to implement the logic in emit-spirv. |
Yeah, we will need to find a way to emit this, independent from how we represent this in the type system or IR. |
2997814
to
0d39787
Compare
8c4ee5c
to
4631bbc
Compare
8bf2a3d
to
9c8ea34
Compare
Goal of this PR
We want to support an array whose size can be specialization constant for shared/global variable e.g.
Overview of the solution:
kIROp_SpecializationConstantOpDecoration
.kIROp_SpecializationConstantOpDecoration
.OpSpecConstantOp
, the existing emit logic doesn't support emittingOpSpecConstantOp
, especially this op can embed arithmetic operation at global scope, where we can only emit arithmetic instruct at local. But there are only few instructs we need to support.Overview of the solution:
Note: This PR is not aimed to support all possible opcodes supported by
OpSpecConstantOp
, only those 32-bit integer opcode, because only those types can be used for array size. For those untypical usage, we can leave in the future to extend, current emit struct should be easy to extend.