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
- Add UniformQuantize() and UniformDequantize() ops.
9
13
- Add Value.WithOutputElementType() to allow change of quantization parameters for operations.
10
-
- Dynamic Shapes (thx @ajroetker)
14
+
11
15
- 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.
Copy file name to clipboardExpand all lines: pkg/types/shapes/shape.go
+44-7Lines changed: 44 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,14 @@
65
65
//
66
66
// If you don't want to panic, but instead return an error through the `graph.Graph`, you can
67
67
// 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.
68
76
package shapes
69
77
70
78
import (
@@ -87,12 +95,41 @@ const DimUnknown = -1
87
95
//
88
96
// Use Make to create a new shape. See example in package shapes documentation.
89
97
typeShapestruct {
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
-
EncodeBoundsbool// 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
+
EncodeBoundsbool
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
96
133
}
97
134
98
135
// Make returns a Shape structure filled with the values given.
0 commit comments