ztcl::tensor cast
Converts the elements to another dtype.
ztcl::tensor cast TENSOR DTYPE
Description
Gives a tensor of DTYPE. A float to i32 goes toward zero, a value out of the range of i32 becomes its nearest end, and NaN becomes 0. A float to a float rounds once.
Returns
A tensor.
Examples
Each example of this page runs after package require ztcl::tensor.
% ztcl::tensor cast [ztcl::tensor of {1.7 -1.7 1e30}] i32
tensor i32 3 {1 -1 2147483647}
Errors
% ztcl::tensor cast [ztcl::tensor ones 2] q8
tensor: unknown dtype "q8": use f32, f64, or i32
-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.