TFLite Support¶
Bitweaver accepts TensorFlow Lite (.tflite) flatbuffers for compilation
and benchmarking. The file format is detected automatically on upload, so
TFLite models go through the same flow as any other Bitweaver model.
This page describes the requirements a .tflite model must meet, the
operators currently supported, and the parameter restrictions on each.
Beta
Compiling .tflite models is under active development. The supported
operator set and parameter coverage are still expanding, and behavior may
change between releases.
Need an op that isn't listed?
Get in touch; new operators are added based on customer demand.
Model requirements¶
- The file must be a valid
.tfliteflatbuffer produced by the TensorFlow Lite converter. - The model must be fully integer-quantized with
int8weights and activations. A subset of element-wise, shape, and pooling ops also acceptuint8activations (noted per operator below). Hybrid (float-activations / int8-weights) models are not supported. - Float32 input and output tensors are allowed when they are bracketed
by
QUANTIZE/DEQUANTIZEops, which is the standard TensorFlow Lite full-integer export pattern. Models withint8input and output tensors are also accepted. - The model must contain a single subgraph. Exports that produce
multiple subgraphs (for example, models with multiple signatures, or
control-flow ops such as
IF/WHILE) are rejected. - The model must have a single input tensor and a single output tensor.
- All tensor shapes must be static. Dynamic-shape tensors are not supported.
- The batch dimension must be 1 for 4D (NHWC) activations.
- Custom operators are not supported.
Supported operators¶
All operators run on int8 activations unless noted otherwise. Fused
activations, where applicable, may be NONE, RELU, or RELU6.
Convolution and dense¶
| Operator | Restrictions |
|---|---|
CONV_2D |
Per-channel or per-tensor weight quantization. Stride is configurable. Dilation must be 1. SAME and VALID padding. Fused activation NONE, RELU, or RELU6. |
DEPTHWISE_CONV_2D |
depth_multiplier must be 1 (or greater than 1 only when input channels = 1). Dilation must be 1. SAME and VALID padding. Fused activation NONE, RELU, or RELU6. |
FULLY_CONNECTED |
Flat 2D inputs only; a non-trivial leading (batched-matmul) dimension is not supported. Fused activation NONE, RELU, or RELU6. |
Pooling and reduction¶
| Operator | Restrictions |
|---|---|
AVERAGE_POOL_2D |
Input and output quantization (scale, zero-point) must match. No fused activation. SAME and VALID padding. |
MAX_POOL_2D |
int8 or uint8. Input and output quantization must match. No fused activation. SAME and VALID padding. |
MEAN |
Reduction over the NHWC spatial axes [1, 2] only (global average pooling). Input must be 4D. |
Element-wise¶
| Operator | Restrictions |
|---|---|
ADD |
Two int8 tensors with NHWC broadcast over size-1 dims; one operand may be constant. Fused activation NONE, RELU, or RELU6. |
MUL |
Two int8 tensors with NHWC broadcast; one operand may be constant. Activation inputs must be 4D NHWC. No fused activation. |
MINIMUM |
Two int8 operands that share quantization, with NHWC broadcast. |
Shape and data movement¶
| Operator | Restrictions |
|---|---|
RESHAPE |
Any shape change permitted by the underlying tensor layout. |
CONCATENATION |
int8 or uint8, along any non-batch axis. Inputs and output must share a dtype. Constant inputs are allowed. No fused activation. |
PAD |
int8 or uint8, rank-4 NHWC. Spatial and channel padding only (no batch-axis padding). Input and output quantization must match. |
MIRROR_PAD |
Rank-4 NHWC, reflect or symmetric mode. No batch-axis padding. Input and output quantization must match. |
SLICE |
Rank-4 NHWC, batch axis kept intact. Input and output quantization must match. |
TRANSPOSE |
int8 or uint8, rank-4 NHWC. The batch axis must stay fixed. Input and output quantization must match. |
RESIZE_BILINEAR |
int8 or uint8, NHWC. Requires half_pixel_centers = True and align_corners = False. Input and output quantization must match. |
RESIZE_NEAREST_NEIGHBOR |
int8 or uint8, NHWC. Requires align_corners = False. Input and output quantization must match. |
Activations¶
| Operator | Restrictions |
|---|---|
RELU |
int8 or uint8. Input and output quantization must match. |
LEAKY_RELU |
int8 or uint8. alpha must be non-negative. |
LOGISTIC |
int8, computed along the last axis. Output zero-point must be -128. |
SOFTMAX |
Computed along the last axis. |
Quantization¶
| Operator | Restrictions |
|---|---|
QUANTIZE |
float32 to int8 / uint8 (boundary quantize), or int8 / uint8 to int8 / uint8 (rescale). |
DEQUANTIZE |
int8 to float32 only (network-output boundary). |
Shape-computation ops are folded automatically
A SHAPE / STRIDED_SLICE / PACK chain that only recomputes a static
reshape target (a common converter artifact) is detected and folded away,
so it does not need to appear in the supported list. These ops are not
supported as general runtime operators.
Fused activations¶
Fused activations on convolution and fully-connected layers map to
operator-level RELU or RELU6. Activations other than RELU and RELU6
(for example TANH or LOGISTIC) are not accepted as fused activations;
include them as separate ops only if they appear in the supported list
above.
Errors¶
If a model fails the checks above, the benchmark transitions to
build_failed and the error is shown in the run details drawer. The most
common messages are:
| Message | Cause | Suggested fix |
|---|---|---|
| Corrupt TFLite file | Flatbuffer header is invalid or the file is truncated. | Re-export the model. |
| Your TFLite model uses unsupported operators | The model uses an operator or parameter combination not listed above. | Adjust the model to use only supported ops, or rebuild with the DeepGate SDK. |
| TFLite model contains multiple subgraphs | The exported .tflite has more than one subgraph (often from multiple signatures or control-flow ops). |
Re-export with a single signature so the converter emits one subgraph. |
| TFLite model has multiple inputs or outputs | The model has more than one input or output tensor (for example a multi-head detector). | Re-export a single-input, single-output model. |