Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions onnxscript/function_libs/torch_lib/ops/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2069,9 +2069,9 @@
query_scaled = op.Mul(query, op.Sqrt(scale))
key_transposed_scaled = op.Mul(key_transposed, op.Sqrt(scale))
# Turn the Boolean mask to float: attn_mask.masked_fill(not attn_mask, -float('inf'))
attn_mask = op.Where(
attn_mask, op.Constant(value_float=0.0), op.Constant(value_float=-float("inf"))
)
zero = op.Constant(value=ir.tensor(0.0, dtype=query.dtype))
neg_inf = op.Constant(value=ir.tensor(-float("inf"), dtype=query.dtype))
attn_mask = op.Where(attn_mask, zero, neg_inf)

Check warning on line 2074 in onnxscript/function_libs/torch_lib/ops/nn.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/function_libs/torch_lib/ops/nn.py#L2072-L2074

Added lines #L2072 - L2074 were not covered by tests
attn_weight = op.Softmax(
op.Add(op.MatMul(query_scaled, key_transposed_scaled), attn_mask),
axis=-1,
Expand Down
Loading