loadLibrary static method

void loadLibrary()

Loads the custom ops library.

This is called automatically when needed, but can be called early to catch loading errors.

Implementation

static void loadLibrary() {
  if (_customOpsLib != null) return;

  final attempted = <String>[];
  _customOpsLib = _loadCustomOpsLibrary(attempted);
  if (_customOpsLib == null) {
    throw UnsupportedError(
      'Failed to load custom ops library.\n'
      'Attempted paths:\n'
      '${attempted.map((p) => '  - $p').join('\n')}',
    );
  }

  // Get the registration function
  final registerFn = _customOpsLib!
      .lookupFunction<
        Pointer<TfLiteRegistration> Function(),
        Pointer<TfLiteRegistration> Function()
      >('TfLiteFlutter_RegisterConvolution2DTransposeBias');

  _registration = registerFn();
}