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.
- Supports CoreML models in both
.mlpackage
and.mlmodelc
(compiled models) formats. - Profiles compilation, loading, and prediction times.
- Includes reports on reasons for unsupported operations on the Neural Engine.
- Visualize the performance metrics through an intuitive interface.
- Sort the cost column to identify the most expensive operations.
- Option to export performance data to JSON.
- Test your models on different compute units like CPU, GPU, and Neural Engine.
- macOS native app using SwiftUI.
- Apple Silicon (M1 and later)
- macOS Sonoma 14.4 and later
- Xcode 15.2 and later (to build)
- dmg version ready to run in the releases page. (it requires macos 14.4 or later)
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.
- Launch CoreMLProfiler.
- Select the processing units (CPU, GPU, Neural Engine) from the UI.
- Load a CoreML model file (
.mlpackage
or.mlmodelc
). - View detailed profiling data for compilation, loading, and prediction times.
- Optionally, enable full profiling mode for more granular insights.
- Export the performance data to a JSON file for further analysis.
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:
- MultiArray
- Int64
- Double
- String
- Dictionary
- Image
- Sequence
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 [email protected].
- Added detailed reports on reasons for unsupported operations on the Neural Engine.
- Enhanced user interface for better visualization of performance metrics.
- Improved sorting and filtering capabilities for the results table.
- Bug fixes and performance improvements.
- Initial release of CoreMLProfiler.
- Support for profiling CoreML models in
.mlpackage
and.mlmodelc
formats. - Detailed performance metrics for compilation, loading, and prediction.
- Option to export performance data to JSON.