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
Commit a84676e
Browse filesBrowse the repository at this point in the historyBrowse files
Pull Request resolved: #24756
## Ulterior Motive
Make buffer storage behave more like texture storage, so one shader can service
both storage types. Earlier commits in this stack gave unary and binary
tensor-tensor ops one shader each, selected by an `op_type` specialization
constant. This commit does the same for tensor-scalar ops.
## Rationale
**What**: The tensor-scalar ops (`pow.Tensor_Scalar`, `mul.Scalar`, and `eq`,
`ne`, `lt`, `le`, `gt`, `ge` `.Scalar`) share one arithmetic and one comparison
shader variant family. The op is selected at dispatch through an `op_type`
specialization constant.
**Why**: Each op had its own variant family, which multiplied the number of
compiled shaders by the number of ops for no change in the code each one runs.
## Details
- Shader variants
- **Before**: one family per op, `{op}_scalar_{storage}_{dtype}_{scalar}`,
with the op inlined through an `OPERATOR` yaml parameter: 8 ops × 2
storages × 4 dtype pairs = 64 shaders.
- **After**: `binary_scalar_op` (`pow`, `mul`) and `binary_scalar_cmp`
(comparisons, which write uint8): 2 × 2 × 4 = 16 shaders. A host `dev`
build of `etvk_ops_bench` shrinks by 514 KiB.
- Op selection
- `apply_binary_scalar_op(op_type, X, Y)` in `binary_scalar.glsl` switches on
the spec constant, which the compiler folds. Each op computes what its
`OPERATOR` expression did, in the same promoted type.
- `op_type` takes `BinaryOpType` values, which gains `kNe`. Only the
tensor-scalar shader implements `kNe`.
- Dispatch
- `add_binary_scalar_op_node` takes a `BinaryOpType` instead of an op name
and picks the comparison family for every op other than `mul` and `pow`.
- `test_vulkan_shader_names.py` checks that every name the tensor-scalar
dispatch can build is generated.
Authored with Claude Code.
ghstack-source-id: 467556317
@exported-using-ghexport
Differential Revision: [D130297164](https://our.internmc.facebook.com/intern/diff/D130297164/)
0 commit comments