Copy
tensorplay.as_tensor
- tensorplay.as_tensor(data, dtype=None, device=None)[source]
Convert
datainto a tensor, sharing storage when possible.If
datais already a tensor with the requested dtype and device, it is returned as-is (no copy). Otherwise it is converted, mirroringtorch.as_tensor.- Parameters:
data (tensor, list, or scalar) – Initial data for the tensor.
dtype (
tensorplay.DType, optional) – the desired data type of the returned tensor.device (
tensorplay.Device, str, optional) – the device of the constructed tensor.
Example:
>>> x = tensorplay.tensor([1.0, 2.0]) >>> tensorplay.as_tensor(x) is x True >>> tensorplay.as_tensor([0, 1, 2], dtype=tensorplay.int64).dtype == tensorplay.int64 True
Help improve this page
Found an error, an unclear step, or a missing example?
tensorplay.are_deterministic_algorithms_enabled
Returns True if the global deterministic flag is turned on. Refer to tensorplay.use_deterministic_algorithms() documentation for more details.
autocast
Instances of autocast serve as context managers or decorators that allow regions of your script to run in mixed precision.
