Skip to content

Commit af37e4f

Browse files
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent b7d9cae commit af37e4f

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

backends/mlx/ops.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3074,20 +3074,35 @@ def _bitwise_not_handler(P: MLXProgramBuilder, n: Node) -> Slot:
30743074
x_meta = n.args[0].meta.get("val")
30753075
out = P.make_or_get_slot(n)
30763076

3077-
if x_meta is not None and x_meta.dtype == torch.bool:
3077+
if x_meta is None or not hasattr(x_meta, "dtype"):
3078+
raise NotImplementedError(
3079+
"aten.bitwise_not requires known input dtype metadata for MLX lowering"
3080+
)
3081+
3082+
if x_meta.dtype == torch.bool:
30783083
P.emit(
30793084
LogicalNotNode(
30803085
x=P.slot_to_tid(args[0]),
30813086
out=P.slot_to_tid(out),
30823087
)
30833088
)
3084-
else:
3089+
elif x_meta.dtype in {
3090+
torch.int8,
3091+
torch.int16,
3092+
torch.int32,
3093+
torch.int64,
3094+
torch.uint8,
3095+
}:
30853096
P.emit(
30863097
BitwiseInvertNode(
30873098
x=P.slot_to_tid(args[0]),
30883099
out=P.slot_to_tid(out),
30893100
)
30903101
)
3102+
else:
3103+
raise NotImplementedError(
3104+
f"aten.bitwise_not on dtype {x_meta.dtype} is not supported for MLX lowering"
3105+
)
30913106
return out
30923107

30933108

0 commit comments

Comments
 (0)