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
11 changes: 9 additions & 2 deletions onnxscript/function_libs/torch_aten/ops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,12 @@ def aten_bitwise_not(self: TInt) -> TInt:
return op.BitwiseNot(self)


@torch_op("aten::bitwise_not", overload=True)
def aten_bitwise_not_bool(self: BOOL) -> BOOL:
# bitwise_not(Tensor self) -> Tensor
return op.Not(self)


@torch_op("aten::bitwise_or")
def aten_bitwise_or(self: TInt, other: TInt) -> TInt:
# bitwise_or.Tensor(Tensor self, Tensor other) -> Tensor
Expand Down Expand Up @@ -3146,9 +3152,10 @@ def aten_margin_ranking_loss(
@torch_op("aten::masked_fill")
def aten_masked_fill(self: TTensor, mask: BOOL, value: TTensor) -> TTensor:
# masked_fill.Tensor(Tensor self, Tensor mask, Tensor value) -> Tensor
mask_cast = op.Cast(mask, to=BOOL.dtype)
# NOTE: Do not attempt to cast `mask` to BOOL because mask should not take any other types.
# `mask` coming in as other types is often an error and should fail the model.
value_cast = op.CastLike(value, self)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a note along this line?

# NOTE: Do not attempt to cast `mask` to BOOL because mask should not take any other types.
# `mask` coming in as other types is often an error and should fail the model.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return op.Where(mask_cast, value_cast, self)
return op.Where(mask, value_cast, self)


def aten_masked_scatter(self: TensorType, mask: TensorType, source: TensorType) -> TensorType:
Expand Down