Artifact builder¶
- class torch_lattice.artifact.builder.ModuleLowering(types, fn, arity)[source]¶
Bases:
object- fn: Callable[[...], ArtifactValue]¶
- lower(builder, name, module, inputs)[source]¶
- Return type:
- Parameters:
builder (TorchLatticeArtifactBuilder)
name (str)
module (Module)
inputs (tuple[ArtifactValue, ...])
- torch_lattice.artifact.builder.module_lowering(*types, arity=1)[source]¶
Register a Torch module lowering method.
- Return type:
Callable[[Callable[...,ArtifactValue]],Callable[...,ArtifactValue]]- Parameters:
- class torch_lattice.artifact.builder.ArtifactValue(value, kind, channels)[source]¶
Bases:
objectA value in the Torch-to-lattice artifact graph.
- class torch_lattice.artifact.builder.TorchLatticeArtifactBuilder(*, input_name='input', output_name='output', input_dtype='f32', batch_size=None, quantize_bits=None, quantize_group_size=32, quantize_scale_dtype='f16', create_default_input=True, input_stride=(1, 1, 1))[source]¶
Bases:
objectExplicit builder for Torch-to-lattice MLIR artifacts.
- Parameters:
- property current: ArtifactValue¶
- sparse_argument(name, *, dtype=None, channels=None, stride=(1, 1, 1))[source]¶
- Return type:
- Parameters:
- lower_module(name, module, *inputs)[source]¶
- Return type:
- Parameters:
name (str)
module (Module)
inputs (ArtifactValue)
- conv3d(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (Conv3d)
input (ArtifactValue)
- subm_conv3d(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (SubmConv3d)
input (ArtifactValue)
- conv_transpose3d(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (ConvTranspose3d)
input (ArtifactValue)
- generative_conv_transpose3d(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (GenerativeConvTranspose3d)
input (ArtifactValue)
- target_conv3d(name, module, input, target)[source]¶
- Return type:
- Parameters:
name (str)
module (TargetConv3d)
input (ArtifactValue)
target (ArtifactValue)
- pool3d(name, module, input=None)[source]¶
- Return type:
- Parameters:
name (str)
module (Pool3d)
input (ArtifactValue | None)
- voxelize(name, *, points, features, batch_indices, active_rows, voxel_size, origin=0.0, reduction='mean', stride=1)[source]¶
- Return type:
- Parameters:
name (str)
points (ArtifactValue)
features (ArtifactValue)
batch_indices (ArtifactValue)
active_rows (ArtifactValue)
reduction (Literal['sum', 'mean'])
- devoxelize(name, *, points, voxels, batch_indices, point_active_rows, voxel_size, origin=0.0, interpolation='nearest')[source]¶
- Return type:
- Parameters:
name (str)
points (ArtifactValue)
voxels (ArtifactValue)
batch_indices (ArtifactValue)
point_active_rows (ArtifactValue)
interpolation (Literal['nearest', 'linear'])
- batch_norm(name, module, input=None)[source]¶
- Return type:
- Parameters:
name (str)
module (BatchNorm)
input (ArtifactValue | None)
- layer_norm(name, module, input=None)[source]¶
- Return type:
- Parameters:
name (str)
module (LayerNorm)
input (ArtifactValue | None)
- rms_norm(name, module, input=None)[source]¶
- Return type:
- Parameters:
name (str)
module (Module)
input (ArtifactValue | None)
- relu(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (Module)
input (ArtifactValue)
- leaky_relu(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
input (ArtifactValue)
- silu(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (Module)
input (ArtifactValue)
- gelu(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
input (ArtifactValue)
- sigmoid(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (Module)
input (ArtifactValue)
- tanh(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (Module)
input (ArtifactValue)
- softplus(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
input (ArtifactValue)
- activation(name, kind, *, input=None, approximate='none', alpha=0.01, beta=1.0, threshold=20.0)[source]¶
- Return type:
- Parameters:
- global_avg_pool(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (GlobalAvgPool)
input (ArtifactValue)
- global_max_pool(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (GlobalMaxPool)
input (ArtifactValue)
- global_pool(name, mode, input=None)[source]¶
- Return type:
- Parameters:
name (str)
mode (Literal['avg', 'max'])
input (ArtifactValue | None)
- linear(name, module, input=None)[source]¶
- Return type:
- Parameters:
name (str)
module (Linear)
input (ArtifactValue | None)
- dropout(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (Dropout)
input (ArtifactValue)
- flatten(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (Flatten)
input (ArtifactValue)
- identity(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (Identity)
input (ArtifactValue)
- instance_norm(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (InstanceNorm)
input (ArtifactValue)
- group_norm(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (GroupNorm)
input (ArtifactValue)
- sparse_crop(name, module, input)[source]¶
- Return type:
- Parameters:
name (str)
module (SparseCrop)
input (ArtifactValue)
- sparse_binary(name, lhs, rhs, op, *, join='outer', lhs_fill=0.0, rhs_fill=0.0)[source]¶
- Return type:
- Parameters:
name (str)
lhs (ArtifactValue)
rhs (ArtifactValue)
op (str)
join (str)
lhs_fill (float)
rhs_fill (float)
- sparse_add(name, lhs, rhs, *, join='outer', lhs_fill=0.0, rhs_fill=0.0)[source]¶
- Return type:
- Parameters:
name (str)
lhs (ArtifactValue)
rhs (ArtifactValue)
join (str)
lhs_fill (float)
rhs_fill (float)
- sparse_cat(name, lhs, rhs, *, join='inner')[source]¶
- Return type:
- Parameters:
name (str)
lhs (ArtifactValue)
rhs (ArtifactValue)
join (str)
- output(value=None, *, name=None)[source]¶
- Return type:
- Parameters:
value (ArtifactValue | None)
name (str | None)
- torch_lattice.artifact.builder.dequantize_artifact_weight(tensor, *, bits, group_size, scale_dtype='f16')[source]¶
Return the logical weight represented by artifact quantization.
This uses the same packing path as artifact export and then unpacks the affine integer payload back to the source tensor layout. Test fixture expected outputs can use it to compare deployment semantics instead of dense pre-quantization training semantics.