Source
Edit
The literal module wraps the XLA Literal type which is a host resident tensor or tuple of tensors.
Literal = ref LiteralObj
-
Literal is reference to a tensor or tuple of tensors resident in host memory in the format used by the XLA library.
Source
Edit
proc `$`(lit: Literal): string {....raises: [ValueError, IOError, OSError,
Exception, XLAError], tags: [WriteIOEffect, RootEffect], forbids: [].}
-
Convert to a tensor and pretty print the result. will convert the data type if needed to cast to a supported tensor type.
Source
Edit
proc convert(lit: Literal; dtype: DataType): Literal {....raises: [XLAError],
tags: [], forbids: [].}
-
Convert type of each element. Allocates a new literal with the result. will raise an XLAError exception if conversion fails. Just returns the orginal tensor if the data type is already matching.
Source
Edit
proc decomposeTuple(lit: Literal): seq[Literal] {....raises: [], tags: [],
forbids: [].}
-
Decompose a literal containing a tuple into a seq of literals. If input is not a tuple then returns a single element sequence.
Source
Edit
proc f32(lit: Literal): Tensor[float32] {....raises: [XLAError, ValueError],
tags: [], forbids: [].}
-
Convert to float32 Tensor. Data type must be F32.
Source
Edit
proc f64(lit: Literal): Tensor[float64] {....raises: [XLAError, ValueError],
tags: [], forbids: [].}
-
Convert to float64 Tensor. Data type must be F64.
Source
Edit
proc i32(lit: Literal): Tensor[int32] {....raises: [XLAError, ValueError],
tags: [], forbids: [].}
-
Convert to int32 Tensor. Data type must be I32.
Source
Edit
proc i64(lit: Literal): Tensor[int64] {....raises: [XLAError, ValueError],
tags: [], forbids: [].}
-
Convert to int64 Tensor. Data type must by I64.
Source
Edit
proc len(lit: Literal): int {....raises: [], tags: [], forbids: [].}
-
Returns count of number of elements.
Source
Edit
proc lit(value`gensym67: int32): Literal {....raises: [], tags: [], forbids: [].}
-
Create new scalar literal from the given value.
Source
Edit
proc lit(value`gensym69: int64): Literal {....raises: [], tags: [], forbids: [].}
-
Create new scalar literal from the given value.
Source
Edit
proc lit(value`gensym71: float32): Literal {....raises: [], tags: [], forbids: [].}
-
Create new scalar literal from the given value.
Source
Edit
proc lit(value`gensym73: float64): Literal {....raises: [], tags: [], forbids: [].}
-
Create new scalar literal from the given value.
Source
Edit
proc newLiteral(dtype: DataType; dims: openArray[int]): Literal {....raises: [],
tags: [], forbids: [].}
-
Allocate a new literal tensor with the given shape. Initialises values to zero.
Source
Edit
proc reshape(lit: Literal; dims: varargs[int]): Literal {....raises: [XLAError],
tags: [], forbids: [].}
-
Returns a view of the same literal with the shape changed. Total number of elements in the tensor must be unchanged or will raise an exception. If one of the dimensions is -1 then this value is inferred from the total number of elements.
Source
Edit
proc toTensor[T: ElemType](lit: Literal): Tensor[T]
-
Create a new tensor form the provided literal. Will raise an XLAError exception if the data type of source and destination do not match.
Source
Edit