Source
Edit
The shape module wraps the XLA Shape type which holds the information on the data layout for any host or device buffers.
DataType = enum
InvalidType, Bool, I8, I16, I32, I64, U8, U16, U32, U64, F16, F32, F64, Tuple,
OpaqueType, C64, BF16, Token, C128
-
DataType lists all of the XLA data types.
Source
Edit
ElemType = float32 or float64 or int64 or int32 or uint8 or bool
-
Allowed types for native nim Tensors
Source
Edit
Shape = object
case kind*: ShapeKind
of ArrayKind:
dtype*: DataType
dims*: seq[int]
of TupleKind:
elems*: seq[Shape]
-
A shape is gives the data type and dimensions either for a single tensor or for a tuple of tensors which might be returned from XLA.
Source
Edit
proc `$`(s: Shape): string {....raises: [Exception], tags: [RootEffect],
forbids: [].}
-
Pretty print shape info. Will recursively generate list of shapes for tuples.
Source
Edit
func `==`(s1, s2: Shape): bool {....raises: [Exception], tags: [RootEffect],
forbids: [].}
-
Have same data type and dimensions?
Source
Edit
proc pad(lo, hi: int): Padding {....raises: [], tags: [], forbids: [].}
-
Padding with given low and high values.
Source
Edit
proc pad(val: int): Padding {....raises: [], tags: [], forbids: [].}
-
Padding with low and high values set to val.
Source
Edit
proc toShape(s: shape_t; topLevel = true): Shape {....raises: [], tags: [],
forbids: [].}
-
Unpack the raw shape_t returned by the xla wrapper.
Source
Edit