embedl_deploy.lattice package#

Subpackages:

Module contents:

Lattice backend — curated pattern lists and convenience API.

Quick start:

import torch
from torchvision.models import resnet50
from embedl_deploy import transform
from embedl_deploy.lattice import LATTICE_OPTIMIZED_PATTERNS

model = resnet50(weights=None).eval()
args = (torch.randn(1, 3, 224, 224),)
deployed = transform(model, args, patterns=LATTICE_OPTIMIZED_PATTERNS).model

Pattern lists#

LATTICE_OPTIMIZED_CONVERSION_PATTERNS

Structural conversions for the Optimized CNN IP, applied before fusion.

LATTICE_ADVANCED_CONVERSION_PATTERNS

Structural conversions for the Advanced CNN IP, applied before fusion.

LATTICE_OPTIMIZED_FUSION_PATTERNS

Fusion-only patterns for the Optimized CNN IP (Conv→[BN]→ReLU).

LATTICE_ADVANCED_FUSION_PATTERNS

Fusion-only patterns for the Advanced CNN IP (Conv→[BN]→ReLU with extended kernel support).

LATTICE_OPTIMIZED_PATTERNS

Union of conversion + fusion patterns for compilation with Lattice SensAI using the Optimized CNN IP. Supports CrossLink-NX and Certus-Pro NX devices.

Patterns in this list will attempt to match operations as closely as possible to the target hardware’s native operators but will not perform major structural changes to the model. This means that the resulting graph structure will be similar to the original PyTorch model, but operation parameters (e.g. kernel size, stride, padding) may be adjusted to be compatible with the target hardware.

Models that use this pattern list may require retraining if node parameters need to be adjusted to be compatible with the target hardware. Refer to the log for details on any adjustments made.

LATTICE_ADVANCED_PATTERNS

Union of conversion + fusion patterns for compilation with Lattice SensAI using the Advanced CNN IP. Supports CrossLink-NX and Certus-Pro NX devices with the Advanced CNN accelerator.

This is a superset of the Optimized CNN patterns. In addition to the parameter-snapping conversions shared with LATTICE_OPTIMIZED_PATTERNS, the Advanced list will include patterns that leverage the wider operator support of the Advanced CNN IP (e.g. depthwise separable convolutions, additional activation functions).

Models that use this pattern list may require retraining if node parameters need to be adjusted to be compatible with the target hardware. Refer to the log for details on any adjustments made.