class
UnsupportedOp
extends
NotImplementedErrorUnsupportedOp(op_name: str, reason: str | None = None)A traced op has no MIL translation, or a refused one.
Named rather than generic because the alternative failure — emitting a package that quietly lacks a layer — produces a model that loads and returns plausible numbers.
Parameters
op_namestrLucid operation that could not be emitted.
reasonstr or None= NoneWhy, when the answer is something other than "nobody has written
the emitter yet". An operation Core ML translates badly — one
whose package would load and be wrong — is refused deliberately,
and pointing the reader at
_emit.py to add a mapping would
send them to write the very thing that was rejected.Examples
A matrix inverse, which Core ML's program dialect has no operation for:
>>> import shutil, tempfile
>>> import lucid, lucid.nn as nn, lucid.coreml as cml
>>> class Inverts(nn.Module):
... def forward(self, x):
... return lucid.linalg.inv(x)
>>> room = tempfile.mkdtemp()
>>> try:
... cml.export(
... Inverts().eval(), lucid.eye(4).reshape(1, 4, 4), f"{room}/m.mlpackage"
... )
... except cml.UnsupportedOp as refusal:
... print(refusal)
lucid.coreml: no Core ML translation for Lucid op 'inv'. Mapped ops: ...
>>> shutil.rmtree(room)