package kaun

  1. Overview
  2. Docs

Module Ptree.TensorSource

Tensor utilities

Get the dtype of the tensor.

Sourceval shape : tensor -> int array

Get the shape of the tensor.

Sourceval numel : tensor -> int

Get the number of elements in the tensor.

Sourceval to_typed : ('a, 'l) Rune.dtype -> tensor -> ('a, 'l) Rune.t option

to_typed dtype t returns Some x when the packed tensor t has the given dtype, with x the typed tensor. Returns None if the dtype does not match.

Sourceval to_typed_exn : ('a, 'l) Rune.dtype -> tensor -> ('a, 'l) Rune.t

to_typed_exn dtype t returns the typed tensor when the dtype matches, or raises Invalid_argument on mismatch.