fn
one_hot_op
→TensorImplPtrint one_hot_op(const int & input, int num_classes, Dtype out_dtype)Python wrappers
Public Python APIs implemented by this engine symbol.Encode integer indices into one-hot float vectors.
Returns a tensor of shape (*input.shape(), num_classes) where the last
axis is the one-hot indicator
The output dtype is out_dtype (typically a floating-point type so the
result can feed directly into a loss function). Indices outside the
range produce all-zero rows. No autograd node
is attached — this op is inference-only.
Parameters
inputTensorImplPtrInteger tensor of arbitrary shape.
num_classesintLength of the one-hot dimension.
out_dtypeDtypeElement type of the output (e.g.
Dtype::Float32).Returns
TensorImplPtrOne-hot tensor of shape (*input.shape(), num_classes) and dtype out_dtype.