Skip to content

Commit 9d35c66

Browse files
authored
Merge pull request #25 from gomlx/value-opname
Added Value.OpName() to allow some introspection into the computation
2 parents eaf840f + 0bc76c5 commit 9d35c66

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

docs/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
## StableHLO
77

8-
- Added `Call()` op (thx @ajroetker)
8+
- Added `Call()` op (thx @ajroetker).
9+
- Added `Value.OpName()` for introspection.
910
- Dynamic Shapes (thx @ajroetker) -- with and without dynamic bounds.
1011
- Added `DimensionBounds` and `EncodeBounds` fields to `Shape` struct
1112
- Added ops: `DynamicReshape`, `DynamicBroadcastInDim`, `DynamicIota`, `DynamicGather`,

pkg/stablehlo/value.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ func (v *Value) String() string {
4949
return "%" + v.name
5050
}
5151

52+
// OpName returns the name of the operation that created this value.
53+
func (v *Value) OpName() string {
54+
if v.stmt == nil {
55+
return "nil"
56+
}
57+
return v.stmt.OpType.String()
58+
}
59+
60+
5261
// ConvertToValidName replaces any characters not in { "0"-"9", "a"-"z", "A-Z", "_" } to a "_",
5362
// making it a valid name for values and function arguments.
5463
func ConvertToValidName(name string) string {

0 commit comments

Comments
 (0)