Weight and activation precision of the exported program.
FLOAT32 is the default because an export should agree with the
model it came from; Core ML's own default is FLOAT16, which the
Neural Engine wants and which costs roughly 1e-4 against the eager
model.
Examples
>>> import shutil, tempfile
>>> import lucid, lucid.nn as nn, lucid.coreml as cml
>>> model = nn.Sequential(nn.Conv2d(3, 16, 3, padding=1), nn.ReLU()).eval()
>>> x, room = lucid.randn(1, 3, 32, 32), tempfile.mkdtemp()
>>> with cml.export(model, x, f"{room}/half.mlpackage",
... precision=cml.Precision.FLOAT16) as package:
... print(package.precision, package.verify(model, x, relative=True) < 1e-2)
FLOAT16 True
>>> shutil.rmtree(room)