Skip to content
fn

read_state_scalar

→double
double read_state_scalar(const TensorImpl & t)

Read a one-element optimizer-state tensor back as a double.

Accepts the tensor on either device and in any of F32, F64, I32 or I64 — a checkpoint loader may rebuild the scalar on the parameter's device, with whatever dtype it was saved in.

Parameters

tconst TensorImpl&
Tensor with exactly one element.

Returns

double

The element, converted to double.

Raises

:runtime_error
If t does not hold exactly one element or has another dtype.