Environment: Windows 11, VSCode + ESP-IDF;
Objective: Convert the best.pt model trained with YOLOV11N into TFLite format using TensorFlow Lite for Microcontrollers (TFLM) for deployment on an ESP32-S3;
Issue: The grouped convolutional layers in best.pt do not seem to be supported by TFLM. After conversion to TFLite format, the grouping information is lost, turning them into regular convolutional layers. This results in a mismatch between the convolutional kernels and tensor inputs, causing errors and crashes during inference on the microcontroller, specifically with the error “TFLITE_DCHECK(node->builtin_data != nullptr);” in conv.cc, even though node->builtin_data appears to be normal.
For example, when my PT model is converted to ONNX and then to TFLite, the information for a certain node in the TFLite file is as follows: Operator 138: CONV_2D, Input Tensor Shape: [1, 10, 10, 128], filter: [128, 3, 3, 1] (the weight order should be O, H, W, I). In this case, the convolutional kernel inputs do not match. How can this issue be resolved?
Hi, @zelia_wang I apologize for the delayed response, As far I know this behavior points directly to a known compatibility gap between complex modern architectures like YOLO and the constrained operator set of TensorFlow Lite for Microcontrollers (TFLM).
We recommend two primary paths to achieve this, First If you are using LiteRT tools, the most robust approach is to convert directly from your PyTorch model (best.pt) using AI Edge Torch.
The AI Edge Torch converter is specifically designed to handle PyTorch models and incorporates internal logic to simplify and rewrite unsupported operations like grouped convolution into compatible TFLite primitives. Try converting your model using the ai_edge_torch.convert() utility please refer this official documentation
Second since you are already using an ONNX intermediary, the most direct fix is to insert a specialized graph transformation step. Use the onnx2tf utility with the --disable_group_convolution flag when converting the ONNX file to a TensorFlow SavedModel
# Export your model to ONNX using Ultralytics first
# Example: yolo export model=best.pt format=onnx
# Then, use onnx2tf to convert to SavedModel with decomposition enabled
onnx2tf -i best.onnx --output_path./yolo_tf_savedmodel --disable_group_convolution
Let us know if the resulting TFLite file resolves the TFLITE_DCHECK error on your ESP32-S3 deployment. If I’ve missed something here please let me know. Thank you for your cooperation and patience.