API Reference
Complete reference for the public API of the dg SDK. Grouped by namespace.
Models
| Class |
Description |
DLGModel |
Base class for DeepGate models. Subclass and override build_model_graph(). |
Layers
Standard
| Class |
Description |
Linear |
Affine linear transformation with optional ReLU. |
Norm |
Element-wise input normalization. Casts integer inputs to float32. |
UpperTriangularLinear |
Linear with upper-triangular weights, in-place-friendly. |
LowerTriangularLinear |
Linear with lower-triangular weights, in-place-friendly. |
Quantized
Utility
| Class |
Description |
Flatten |
NCHW → NHWC permute then flatten. |
Pad |
Right-pad the last dimension with zeros. |
Slice |
Keep the first keep_bits entries of the last dimension. |
Expand |
Repeat the last dimension repeat times. |
BlockShuffle |
Fixed-permutation block shuffle of the last dimension. |
MaxPool2d |
Non-quantized 2D max pooling. |
BitShift |
Bit-shift with integer truncation and straight-through gradients. |
Reshape |
NCHW → NHWC permute then reshape to a target shape. |
Concat |
Concatenate a list of tensors along a non-batch dimension. |
Training
| Symbol |
Description |
Train |
Orchestrates training over epochs. Alias for dg.train.Trainer. |
freeze_backbone |
Freeze every layer except the head, for fine-tuning. |
Evaluation
| Function |
Description |
get_acc |
Top-1 classification accuracy over a dataset. |
compute_metric |
Generic per-batch metric loop under no_grad. |
Model Hub
| Function |
Description |
from_pretrained |
Load a model from a local directory or from the DeepGate hub. |