Skip to content

Commit aafc57d

Browse files
authored
Merge pull request #16 from gomlx/doc-updates
Documentation updates
2 parents 7cf3fde + 8386c40 commit aafc57d

2 files changed

Lines changed: 52 additions & 11 deletions

File tree

docs/CHANGELOG.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# Next: Dynamic Shapes (thx @ajroetker); added `Call()`; Quantized shapes;
22

3-
* Updated `DefaultCPUVersion` to "v0.83.4" (`pjrt-cpu-binaries` version)
4-
* Added `Call()` op (thx @ajroetker)
5-
* Quantization:
3+
- Updated `DefaultCPUVersion` to "v0.83.4" (`pjrt-cpu-binaries` version)
4+
- Added `Call()` op (thx @ajroetker)
5+
- Dynamic Shapes (thx @ajroetker) -- with and without dynamic bounds.
6+
- Added `DimensionBounds` and `EncodeBounds` fields to `Shape` struct
7+
- Added ops: `DynamicReshape`, `DynamicBroadcastInDim`, `DynamicIota`, `DynamicGather`,
8+
`DynamicPad`, `DynamicConv`.
9+
- Quantization:
610
- Add Quantization field to shapes.Shape.
711
- Add i2, i4, ui2 and ui4 DTypes.
812
- Add UniformQuantize() and UniformDequantize() ops.
913
- Add Value.WithOutputElementType() to allow change of quantization parameters for operations.
10-
- Dynamic Shapes (thx @ajroetker)
14+
1115
- Ops choose the "innermost" scope of their operands -- meaning they are added the closure functions if they are operating on a value that is local to the closure.
1216

1317
# v0.1.4

pkg/types/shapes/shape.go

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565
//
6666
// If you don't want to panic, but instead return an error through the `graph.Graph`, you can
6767
// use the `Node.AssertDims()` method. So it would look like `logits.AssertDims(batchSize, shapes.DimUnknown)`.
68+
//
69+
// ## Experimental extensions:
70+
//
71+
// - Dynamic shapes: using DimUnknown (-1) for axes with unknown/dynamic dimensions.
72+
// Dynamic ranked tensors are not supported.
73+
// - Dynamic bounds: DimensionBounds for dynamic dimensions, when Dimensions[axis] == DimUnknown.
74+
// - Quantization: not supported by PJRT yet, but the library will generate valid StableHLO
75+
// for quantized types.
6876
package shapes
6977

7078
import (
@@ -87,12 +95,41 @@ const DimUnknown = -1
8795
//
8896
// Use Make to create a new shape. See example in package shapes documentation.
8997
type Shape struct {
90-
DType dtypes.DType
91-
Dimensions []int
92-
DimensionBounds []int // Upper bounds for dynamic dimensions (when Dimensions[i] == DimUnknown). nil or len(DimensionBounds)==len(Dimensions). 0 means no bound.
93-
TupleShapes []Shape // Shapes of the tuple, if this is a tuple.
94-
Quantization *Quantization // Quantization metadata for quantized types.
95-
EncodeBounds bool // Whether to encode DimensionBounds in StableHLO output. Set to true for ops that require bounded dynamism (e.g., dynamic_reshape).
98+
// DType is the data type of the unit element in a tensor. Enumeration defined in github.com/gomlx/go-xla/pkg/types/dtypes
99+
DType dtypes.DType
100+
101+
// Dimensions (lengths) for each axis of the tensor/array being represented.
102+
// It can be 0 (0-lengthed tensor) and DimUnknown (-1) for unknown/dynamic dimensions.
103+
//
104+
// Dimensions also encode the rank (== len(Dimensions)) of the tensor.
105+
// Dynamic ranked tensors are not supported.
106+
//
107+
// If you are going to use this to create a new shape, remember to clone it
108+
// (see Shape.Clone()).
109+
Dimensions []int
110+
111+
// DimensionBounds for dynamic dimensions, when Dimensions[axis] == DimUnknown.
112+
// nil or len(DimensionBounds)==len(Dimensions). 0 means no bound.
113+
//
114+
// It is set to nil for shapes that are not dynamic or have no bounds.
115+
DimensionBounds []int
116+
117+
// EncodeBounds whether to encode DimensionBounds in StableHLO output. Set to true for ops that require
118+
// bounded dynamism (e.g., dynamic_reshape).
119+
EncodeBounds bool
120+
121+
// TupleShapes of the tuple, if this is a tuple.
122+
TupleShapes []Shape
123+
124+
// Quantization metadata for quantized shapes.
125+
// Not supported by PJRT yet, but the library will generate valid StableHLO
126+
// for quantized types.
127+
//
128+
// Notice that one can implement quantization around stablehlo, simply managing themselves the conversions
129+
// at every step/operation.
130+
//
131+
// It is set to nil for shapes that are not quantized.
132+
Quantization *Quantization
96133
}
97134

98135
// Make returns a Shape structure filled with the values given.
@@ -280,14 +317,14 @@ func (s Shape) Clone() (s2 Shape) {
280317
s2.DType = s.DType
281318
s2.Dimensions = slices.Clone(s.Dimensions)
282319
s2.DimensionBounds = slices.Clone(s.DimensionBounds)
320+
s2.EncodeBounds = s.EncodeBounds
283321
if s.TupleSize() > 0 {
284322
s2.TupleShapes = make([]Shape, 0, len(s.TupleShapes))
285323
for _, subShape := range s.TupleShapes {
286324
s2.TupleShapes = append(s2.TupleShapes, subShape.Clone())
287325
}
288326
}
289327
s2.Quantization = s.Quantization.Clone()
290-
s2.EncodeBounds = s.EncodeBounds
291328
return
292329
}
293330

0 commit comments

Comments
 (0)