Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ xcuserdata/
# Agents
.claude/*.local.*
extension/pybindings/mlx.metallib

# Auto-generated flatbuffers
backends/mlx/serialization/mlx_graph_schema.py
7 changes: 7 additions & 0 deletions backends/mlx/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
AsStridedNode,
AsTypeNode,
Atan2Node,
BitwiseXorNode,
BroadcastToNode,
CeilNode,
ClipNode,
Expand Down Expand Up @@ -490,6 +491,12 @@ def handler(P: MLXProgramBuilder, n: Node) -> Slot:
"aten.ne",
True,
),
(
[torch.ops.aten.bitwise_xor.Tensor, torch.ops.aten.bitwise_xor.Scalar],
BitwiseXorNode,
"aten.bitwise_xor",
True,
),
]


Expand Down
9 changes: 8 additions & 1 deletion backends/mlx/serialization/schema.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,12 @@ table MetalKernelNode {
init_value: float = null;
}

table BitwiseXorNode {
a: Tid;
b: Tid;
out: Tid;
}

// =============================================================================
// Union of all op types
// =============================================================================
Expand Down Expand Up @@ -1113,7 +1119,8 @@ union OpNode {
GatherMmNode,
GatherQmmNode,
ScanNode,
MetalKernelNode
MetalKernelNode,
BitwiseXorNode
// BC: Add new op nodes here (append only)
}

Expand Down
3 changes: 3 additions & 0 deletions backends/mlx/test/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -4205,6 +4205,9 @@ def create_model(self) -> nn.Module:
# logical
{"op_name": "logical_and", "op_fn": torch.logical_and, "shapes": [(2, 3, 4), (10,), (4, 8)], "dtypes": [torch.bool], "input_fn_a": _bool_input_fn(), "input_fn_b": _bool_input_fn()},
{"op_name": "logical_or", "op_fn": torch.logical_or, "shapes": [(2, 3, 4), (10,), (4, 8)], "dtypes": [torch.bool], "input_fn_a": _bool_input_fn(), "input_fn_b": _bool_input_fn()},
# bitwise
{"op_name": "bitwise_xor_bool", "op_fn": torch.bitwise_xor, "shapes": _SHAPES_3, "dtypes": [torch.bool], "input_fn_a": _bool_input_fn(), "input_fn_b": _bool_input_fn()},
{"op_name": "bitwise_xor_int", "op_fn": torch.bitwise_xor, "shapes": _SHAPES_3, "dtypes": [torch.int32, torch.int64], "input_fn_a": _int_input_fn(0, 256), "input_fn_b": _int_input_fn(0, 256)},
]
# fmt: on

Expand Down
Loading