package caisar-ir
Library
Module
Module type
Parameter
Class
Class type
type shape = Base.int Base.array
val pp_shape :
Ppx_deriving_runtime.Format.formatter ->
shape ->
Ppx_deriving_runtime.unit
val show_shape : shape -> Ppx_deriving_runtime.string
create sh
initialize a tensor with the given shape sh
with a default value, depending of the type of the tensor
type ('a, 'b) t_kind =
| K_int : (Base.int64, Stdlib.Bigarray.int64_elt) t_kind
| K_float : (Base.float, Stdlib.Bigarray.float64_elt) t_kind
get t idx
returns the value in tensor t
stored at coordinates idx
. Throw an error if the coordinate is invalid.
set_idx t idx v
sets value v
for tensor t
at idx
. Throw an error if the coordinate is invalid.
equal f t1 t2
applies f
to all values of t1
and t2
, and returns true if all applications of f returned true.
get_shape t
returns the shape of t
.
flatten t
returns a flattened version of t
.
num_neurons sh
returns the total number of neurons given a shape
get flatnd_idx idx sh flt
returns the value that would be stored at index idx
under a tensor of shape sh
, given the flattened version of this tensor flt
.
transpose_2d t
returns a copy of the tensor t
with its two last dimension exchanged.
unsqueeze sh1 sh2
returns the lowest common shape between sh1
and sh2
, and None if there is no common shape. A common shape is when a shape of higher dimension has only 1 coordinates on non-shared dimensions with the other.
val unsqueeze : sh1:shape -> sh2:shape -> shape Base.option