beetlebug▾
/

ztcl::tensor bytes

Gives the little-endian bytes of the elements.

ztcl::tensor bytes TENSOR

Description

Gives a byte string with the elements in row-major order, little-endian. raw reads it back.

Returns

A byte string.

Examples

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

% set a [ztcl::tensor of {{1 2 3} {4 5 6}}]; string length [ztcl::tensor bytes $a]
24

% set a [ztcl::tensor of {{1 2 3} {4 5 6}}]; ztcl::tensor equal [ztcl::tensor raw f32 {2 3} [ztcl::tensor bytes $a]] $a
1

Errors

% ztcl::tensor bytes {a b}
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.