Skip to main content

ClikaRT::ops::masked_fill

function

masked_fill()

Tensor masked_fill(
    Tensor x,
    Tensor mask,
    ScalarOrTensor value
)

Replace the elements of x where mask is true with value.

mask is Bool and broadcasts to x's shape; value is a literal or a 0-D Tensor.

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when mask is not Bool or does not broadcast to x (code_name() carries the reason).

Returns: a new tensor shaped like x.

auto masked = ClikaRT::ops::masked_fill(scores, pad_mask, -1e9);

Declared in ClikaRT/compute/ops.h, line 2497