Add GEN_INDEX pointwise op#359
Open
rsuderman wants to merge 4 commits intoiree-org:mainfrom
Open
Conversation
Emits the output as a linalg.generic that materializes the iteration index along a configurable axis (via PointwiseAttr::setGenIdxAxis). The generic is bridged back to torch via torch_c.from_builtin_tensor so the result feeds the standard output permute. Also adds buildBuiltinTensorTypeStr / getSignlessElementTypeAsm / getIdentityAffineMapAsm / getIteratorTypesAsm helpers and relaxes the lit-test MLIR indentation check to allow nested region bodies. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
IanWood1
reviewed
Apr 21, 2026
| {PointwiseAttr::Mode::FLOOR, 1}, | ||
| {PointwiseAttr::Mode::GELU_APPROX_TANH_FWD, 1}, | ||
| {PointwiseAttr::Mode::GELU_FWD, 1}, | ||
| {PointwiseAttr::Mode::GEN_INDEX, 1}, |
Member
There was a problem hiding this comment.
It's a bit strange that it takes an input that it never uses. Is this just for shape inference?
Contributor
Author
There was a problem hiding this comment.
Correct — IN_0 is only used for shape inference. The Graph::pointwise single-operand overload (graph.h:937) feeds the input's shape through inferPropertiesNode so the OUT_0 dims/strides can be derived without having to set them explicitly. This matches cuDNN's Graph API shape for GEN_INDEX (it takes an input tensor whose shape drives the output shape). The emitted linalg.generic doesn't consume IN_0's values.
- Move getSignlessElementTypeAsm to types.h, alongside new isFloatDataType /
isIntegerDataType helpers driven by a new per-DataType Category column in
FUSILLI_FORALL_DATA_TYPES. Covers every float dtype (including FP8E5M2) and
replaces the bug-prone substr("i") check.
- Use interleave() in getIdentityAffineMapAsm / getIteratorTypesAsm.
- Enforce axis range and dtype correctness in PointwiseNode::postValidateNode
for GEN_INDEX; keep the emitter asserts as safety nets.
- Add unit tests for the new MLIR / dtype helpers.
- Add an int-dtype lit test variant for GEN_INDEX.
- Fold the dedicated pointwise_gen_index sample into pointwise_unary_ops so
the op is exercised with the other unary pointwise ops.
Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
Member
sjain-stanford
left a comment
There was a problem hiding this comment.
I gave it a cursory look but would like to do another closer review later today or Thursday.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Emits the output as a linalg.generic that materializes the iteration index along a configurable axis (via PointwiseAttr::setGenIdxAxis). The generic is bridged back to torch via torch_c.from_builtin_tensor so the result feeds the standard output permute.
Also adds buildBuiltinTensorTypeStr / getSignlessElementTypeAsm / getIdentityAffineMapAsm / getIteratorTypesAsm helpers and relaxes the lit-test MLIR indentation check to allow nested region bodies.