mnn library

MNN bindings for Dart.

Copyright (c) 2025, rainyl. All rights reserved. Use of this source code is governed by a Apache 2.0 license that can be found in the LICENSE file.

Enums

DataType
DimensionFormat
DimensionType
ErrorCode
Error code enum
ForwardType
HalideTypeCode
Types in the halide type system. They can be ints, unsigned ints, or floats (of various bit-widths), or a handle (which is always 64-bits). Note that the int/uint/float values do not imply a specific bit width (the bit width is expected to be encoded in a separate value).
HandleDataType
HintMode
Hint mode enum
InputType
MapType
MemoryType
SessionInfoCode
SessionMode
StbirDataType
StbirEdge
=============================================================== Medium-complexity API
StbirFilter
StbirPixelLayout
stbir_pixel_layout specifies: number of channels order of channels whether color is premultiplied by alpha for back compatibility, you can cast the old channel count to an stbir_pixel_layout

Constants

MNN_GPU_MEMORY_BUFFER → const int
OpenCL_MEMORY_BUFFER
MNN_GPU_MEMORY_IMAGE → const int
OpenCL_MEMORY_IMAGE
MNN_GPU_RECORD_BATCH → const int
10 kernels record into one recording.(OpenCL) All ops share one commandBuffer.(Vulkan)
MNN_GPU_RECORD_OP → const int
The kernels in one op execution record into one recording.(OpenCL)
MNN_GPU_TUNING_FAST → const int
Fast tuning, performance may not good.(OpenCL)
MNN_GPU_TUNING_HEAVY → const int
Heavily tuning, usually not suggested.(OpenCL/Vulkan)
MNN_GPU_TUNING_NONE → const int
Copyright (c) 2025, rainyl. All rights reserved. Use of this source code is governed by a Apache 2.0 license that can be found in the LICENSE file. Forbidden tuning, performance not good.(OpenCL/Vulkan)
MNN_GPU_TUNING_NORMAL → const int
Normal tuning, performance may be ok.(OpenCL)
MNN_GPU_TUNING_WIDE → const int
Widely tuning, performance good. Default.(OpenCL/Vulkan)
MNN_MEMORY_HIGH → const int
MNN_MEMORY_LOW → const int
MNN_MEMORY_NORMAL → const int
MNN_POWER_HIGH → const int
MNN_POWER_LOW → const int
MNN_POWER_NORMAL → const int
MNN_PRECISION_HIGH → const int
MNN_PRECISION_LOW → const int
MNN_PRECISION_LOW_BF16 → const int
MNN_PRECISION_NORMAL → const int

Functions

array2string(List<num> data, List<int> shape, {PrintOptions options = const PrintOptions(), String separator = ', ', String prefix = '', String suffix = ''}) String
calcColumnWidths(List<num> data, List<int> shape, PrintOptions options) List<int>
formatAligned(num v, int width, PrintOptions options) String
formatFloat(num x, int precision, bool suppress) String
formatInt(int x) String
getVersion() String
MnnAssert(bool condition, String message) → void
mnnRun(ErrorCode func()) → void
mnnRunAsync0<T>(ErrorCode func(mnn_callback_0 callback), void onComplete(Completer<T> completer)) Future<T>

Exceptions / Errors

MNNException