Rate this Page
★ ★ ★ ★ ★

TensorDictBase.quint4x2#

TensorDictBase.quint4x2(*, cast_filter: Callable | None = None) → Self#

Returns a tensordict whose tensor leaves are cast to torch.quint4x2.

Deprecated

A quantized tensor needs a scale and a zero point, which a dtype cast cannot supply, so this method raises for any floating-point entry. It will be removed in TensorDict 0.18. Use td.apply(lambda x: torch.quantize_per_tensor(x, scale, zero_point, torch.quint4x2)) instead.

Keyword Arguments:

cast_filter (Callable, optional) – a predicate fn(key, value) -> bool that selects the tensor leaves to cast, as in to(). Defaults to None, which casts every tensor leaf (a tensorclass uses its own cast_filter, if it declares one).

Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.