Skip to content
fn

masked_fill_op

→TensorImplPtr
int masked_fill_op(const int & a, const int & mask, double value)

Python wrappers

Public Python APIs implemented by this engine symbol.

Replace masked positions with a scalar value.

Returns a tensor equal to a except at positions where mask is true, which are filled with value.

Parameters

aTensorImplPtr
Input tensor.
maskTensorImplPtr
Boolean mask of the same shape as a.
valuedouble
Fill value (cast to the dtype of a).

Returns

TensorImplPtr

Tensor of the same shape and dtype as a.

Notes

Backward routes grad_out through positions where mask is false (the values that survived the fill); positions where mask is true receive zero gradient. Neither mask nor value is differentiable.