CoreMLProfiler is a macOS application designed to profile CoreML models. It provides detailed estimates for each operation's time, allowing users to view and filter results in a table. The application supports both .mlpackage
and .mlmodelc
formats and offers comprehensive insights into compilation, loading, and prediction times. Users can select different compute units and visualize performance metrics through an intuitive interface, with comprehensive statistics on all aspects of model profiling, including report on reasons for unsupported operations on the Neural Engine.
.mlpackage
and .mlmodelc
(compiled models) formats.You can download the app from releases or build the project.
Download the latest version (dmg file) from the releases page
If you want to build the project, follow these steps (requires Xcode 15.2 or later).
Clone the repository:
git clone https://github.com/fguzman82/CoreMLProfiler
Open the project in Xcode:
cd CoreMLProfiler
open CoreMLProfiler.xcodeproj
Build and run the project in Xcode.
.mlpackage
or .mlmodelc
).You can test CoreMLProfiler with your own models or download models from the CoreML community on Hugging Face. here.
The heart of CoreML Profiler consists of two main components: 1) utilizing the MLComputePlan()
class from the CoreML Framework, which allows the extraction of costs for each operation of the model, and 2) a prediction function that uses a dummy input, automatically created according to the data structure reported in the CoreML Package.
Here are the data structures that can be automatically generated as dummy inputs to test the prediction function and estimate prediction times:
The selected mlpackage file is first compiled to generate the compiled mlmodelc model. Then, loadModel
is executed with the selected processing units (CPU, GPU, Neural Engine). The input types supported by the model are inspected to launch the createDummyInput
function, which emulates random data according to the input type. With this input, the model prediction is executed to estimate prediction times and compute the duration of each operation extracted from MLComputePlan()
.
The compilation, load, and predict processes are repeated several times to collect statistics on the times to report them in the profile visualization.
When the file is already compiled (type mlmodelc), the compilation process is skipped, and the remaining steps described above are performed.
The Full Profile option (enabled by default) is in Beta. This option enables creating dummy input and performing the prediction. When this option is disabled, only the cost of each operation is computed, and execution times are not estimated.
A log terminal is included to monitor the profiling flow and visualize errors if any.
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue to discuss changes or improvements.
Special thanks to @FL33TW00D for his interesting discovery regarding the ANE report.
CoreMLProfiler is licensed under the MIT License. See the LICENSE file for more details.
For any questions or inquiries, please contact Fabio Guzman at fabioandres.guzman@gmail.com.
.mlpackage
and .mlmodelc
formats.