Skip to content

Commit be52599

Browse files
authored
feat: provide guidance when registering custom op (#2530)
1 parent e85b3ee commit be52599

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
@@ -249,6 +249,11 @@ def _convert_to_meta_function(func):
249249

250250

251251
def _get_meta_function_from(custom_op: CustomOpDef) -> Callable[[Any], TensorProxy | tuple[TensorProxy, ...]]:
252+
if custom_op._abstract_fn is None:
253+
raise ValueError(
254+
f"Custom op {custom_op._qualname} has no _abstract_fn defined. "
255+
"You must provide an abstract function (using @torch.library.register_fake) when defining the custom op."
256+
)
252257
return _convert_to_meta_function(custom_op._abstract_fn)
253258

254259

0 commit comments

Comments
 (0)