Skip to content

TECHNICANGEL/qualcomm-ai-stack-patched

Repository files navigation

Qualcomm AI Stack SDK - Patched Version

This SDK has been patched to fix critical memory corruption issues in the model converter tools, specifically when handling complex graph transformations and shape inference.

Key Fixes & Patches

1. Python-based Shape Re-inference

  • Core Fix: Replaced buggy C++ shape inference logic with a robust Python implementation in qti.aisw.converters.qnn_backend.qnn_backend_base.reinfer_graph_shapes.
  • Topological Pass: Added a comprehensive graph traversal that re-computes all buffer shapes using Python logic to ensure consistency across the entire network.

2. Memory Corruption Prevention

  • Python Caching: Dimensons, shapes, and operation parameters are now cached in Python objects to avoid direct calls to unstable C++ library functions which were causing segmentation faults and data corruption.
  • Safe Property Accessors: Overrode __setattr__ and added Python-backed property accessors for critical metadata like perm, transpose, and dims.

3. Op-Specific Robustness Fixes

  • Conv2D: Improved shape inference with better NCHW/NHWC layout detection and support.
  • MatMul: Added auto-detection and fixing of transpose flags when inner dimensions do not match, preventing conversion failures.
  • BatchNorm & Element-wise Ops: Ensured output shapes strictly match input shapes to prevent stale dimensions from propagating.
  • Reshape & Transpose: Fixed NCHW to NHWC transformation logic and perm parameter handling.

4. Stability Improvements

  • Input/Output Buffers: Removed direct C++ calls to inputs() and outputs() on certain nodes to avoid memory corruption during graph optimization passes.

Contents

  • bin/: Executables and setup scripts.
  • docs/: Original documentation for QNN, SNPE, and Genie.
  • examples/: Sample code and models.
  • include/: C++ header files.
  • lib/: Shared libraries and Python modules (Patched).
  • share/: Additional resources and templates.

Setup

Refer to bin/envsetup.ps1 (Windows) or bin/envsetup.sh (Linux) to set up your environment variables. Individual READMEs for QNN and Genie are available in the root directory:

  • QNN_README.txt
  • GENIE_README.txt

Support the Project

If these patches saved you hours of debugging or prevented a system crash, consider supporting the continued maintenance of this repository.

Donate with PayPal

PayPal Account: drifterself01@gmail.com

About

Patched Qualcomm AI Stack SDK fixing critical memory corruption and shape inference bugs in model converter tools (QNN/SNPE).

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors