beetlebug▾
/

ztcl::tensor check

Checks a tensor and gives it as a tensor value.

ztcl::tensor check TENSOR

Description

Gives the tensor value of TENSOR. A string reads as a tensor: its dtype, its shape, and the count and the form of its values are checked.

Returns

A tensor.

Examples

Each example of this page runs after package require ztcl::tensor.

% ztcl::tensor check {tensor f32 2 {1 2}}
tensor f32 2 {1.0 2.0}

Errors

% ztcl::tensor check {tensor f32 {2 2} {1 2 3}}
tensor: the shape {2 2} of f32 needs 4 values (16 bytes), and the value has 3
-errorcode ZTCL TENSOR

% ztcl::tensor check {a b c}
not a tensor
-errorcode ZTCL TENSOR

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.4
Compute cost
A cost for each element operation by its kind (a copy, an add, a division, a math function, a multiply-add of a matmul), set so that one compute unit takes about the time of one unit of plain Tcl. docs/modules/tensor.md has the table.