Skip to content

Commit 25ce595

Browse files
authored
Disallow custom_op that mutates arguments (#2603)
1 parent 22e943c commit 25ce595

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

thunder/torch/custom_op.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ def _register_custom_op(custom_op: CustomOpDef) -> Symbol:
336336
torch_opoverload_packet: OpOverloadPacket = torch_opoverload._overloadpacket
337337

338338
schema: FunctionSchema = torch_opoverload._schema
339+
baseutils.check(
340+
not schema.is_mutable,
341+
lambda: f"{custom_op} mutates one or more of its arguments, which is not supported",
342+
)
343+
339344
schema_arguments: list[Argument] = schema.arguments
340345
tensor_indices: tuple[int] = tuple(
341346
i

0 commit comments

Comments
 (0)