Tiny machine learning (TinyML) enables low-power microcontrollers to leverage the power of artificial intelligence without remote computing resources. Typically, developing a TinyML application primarily relies on existing TinyML frameworks, which provide runtime APIs for loading and executing machine learning models. However, such framework-based TinyML development has limitations in terms of portability, programmability, and resource efficiency.
To address these challenges, this work introduces TinyGen, a code generation framework for TinyML. TinyGen generates portable high-level code directly from a target model without depending on external runtime APIs. It statically analyzes the tensor and operator usage of the target model to enable compact code generation. This work demonstrates that TinyGen can reduce binary code size by 38.4% compared to an existing TinyML framework while requiring fewer lines of code to implement TinyML applications.