Skip to content

Export model

Once you have quantized your PyTorch nn.Module, dg.export lowers it to schema.json for on-device deployment.

For complete working examples, see the Tutorials page.

ANN models

import dg

model = MyConvNet()  # with dg.Norm as first layer
quantized = dg.post_training_quantize(model, calib_dataset, num_samples=1024)
schema = dg.export(quantized)

For models with no dg.Norm layer, pass input_boundary="int8" to export() to skip the compiler's input quantize step (useful for memory-constrained deployments or when input is already quantized); see the export API reference for details.

Logic models

from dg import export, trace

schema = export(trace(model, (example,)))

Logic models (built from LUTLinear, BitShift, etc.) compute on bits with no quantization, so trace and export are the whole path. Trace with a batch of 2+ samples. See Logic Layers for details.