ARM-software / armnn

Arm NN ML Software. The code here is a read-only mirror of https://review.mlplatform.org/admin/repos/ml/armnn
https://developer.arm.com/products/processors/machine-learning/arm-nn
MIT License
1.16k stars 308 forks source link

Avoid use of deprecated TfLiteRegistrationExternal #785

Closed jonhoo closed 1 week ago

jonhoo commented 3 weeks ago

As of tf.lite 2.17, to quote the release announcement:

  • C API:
    • The experimental TfLiteRegistrationExternal type has been renamed as TfLiteOperator, and likewise for the corresponding API functions.

Aliases for them remain for now behind a #ifdef guard, but that's apparently just as a short-term hack (https://github.com/tensorflow/tensorflow/pull/64418) – they're likely to be fully removed soon. I'd recommend moving away from these to the new names.

jonhoo commented 3 weeks ago

Oh, and just to make this issue easier to find for others, this manifests as errors like the following:

/build/source/delegate/opaque/src/armnn_delegate.cpp: In function 'TfLiteStatus armnnOpaqueDelegate::DoPrepare(TfLiteOpaqueContext*, TfLiteOpaqueDelegate*, void*)':
/build/source/delegate/opaque/src/armnn_delegate.cpp:187:13: error: 'TfLiteRegistrationExternalCreate' was not declared in this scope; did you mean 'TfLiteRegistrationExternal'?
  187 |             TfLiteRegistrationExternalCreate(kTfLiteBuiltinDelegate,
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |             TfLiteRegistrationExternal
/build/source/delegate/opaque/src/armnn_delegate.cpp:195:5: error: 'TfLiteRegistrationExternalSetInit' was not declared in this scope; did you mean 'TfLiteRegistrationExternal'?
  195 |     TfLiteRegistrationExternalSetInit(
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     TfLiteRegistrationExternal
/build/source/delegate/opaque/src/armnn_delegate.cpp:217:5: error: 'TfLiteRegistrationExternalSetFree' was not declared in this scope; did you mean 'TfLiteRegistrationExternal'?
  217 |     TfLiteRegistrationExternalSetFree(
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     TfLiteRegistrationExternal
/build/source/delegate/opaque/src/armnn_delegate.cpp:229:5: error: 'TfLiteRegistrationExternalSetPrepare' was not declared in this scope; did you mean 'TfLiteRegistrationExternal'?
  229 |     TfLiteRegistrationExternalSetPrepare(
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     TfLiteRegistrationExternal
/build/source/delegate/opaque/src/armnn_delegate.cpp:242:5: error: 'TfLiteRegistrationExternalSetInvoke' was not declared in this scope; did you mean 'TfLiteRegistrationExternal'?
  242 |     TfLiteRegistrationExternalSetInvoke(
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     TfLiteRegistrationExternal
/build/source/delegate/opaque/src/armnn_delegate.cpp: In member function 'TfLiteIntArray* armnnOpaqueDelegate::ArmnnOpaqueDelegate::IdentifyOperatorsToDelegate(TfLiteOpaqueContext*)':
/build/source/delegate/opaque/src/armnn_delegate.cpp:347:41: error: 'TfLiteRegistrationExternalGetBuiltInCode' was not declared in this scope; did you mean 'TfLiteRegistrationExternal'?
  347 |             unsupportedOperators.insert(TfLiteRegistrationExternalGetBuiltInCode(tfLiteRegistration));
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                         TfLiteRegistrationExternal
[ 27%] Building CXX object src/backends/reference/workloads/CMakeFiles/armnnRefBackendWorkloads.dir/RefConvolution2dWorkload.cpp.o
/build/source/delegate/opaque/src/armnn_delegate.cpp: In static member function 'static TfLiteStatus armnnOpaqueDelegate::ArmnnSubgraph::VisitNode(armnnOpaqueDelegate::DelegateData&, TfLiteOpaqueContext*, TfLiteRegistrationExternal*, TfLiteOpaqueNode*, int)':
/build/source/delegate/opaque/src/armnn_delegate.cpp:703:13: error: 'TfLiteRegistrationExternalGetBuiltInCode' was not declared in this scope; did you mean 'TfLiteRegistrationExternal'?
  703 |     switch (TfLiteRegistrationExternalGetBuiltInCode(tfLiteRegistration))
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |             TfLiteRegistrationExternal
/build/source/delegate/opaque/src/armnn_delegate.cpp:789:46: error: 'TfLiteRegistrationExternalGetCustomName' was not declared in this scope; did you mean 'TfLiteRegistrationExternal'?
  789 |             std::string customOperatorName = TfLiteRegistrationExternalGetCustomName(tfLiteRegistration);
      |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                              TfLiteRegistrationExternal
jonhoo commented 3 weeks ago

For reference, the actual change upstream happened in https://github.com/tensorflow/tensorflow/pull/64173

Colm-in-Arm commented 3 weeks ago

Hello Jonhoo

Currently Arm NN is still on TfLite v2.15.0. It won't be updated for the 24.08 release. We have still not decided if it will be updated during 24.11 and a change such as this would make us slow to change.

Are there specific features in 2.17 that you think might be useful?

Colm.

jonhoo commented 3 weeks ago

Hey Colm,

No, there's nothing in particular I'm looking for in 2.17. I just encountered this because I am maintaining a Nix package internally for armnn, and as Nix upgrades its versions of various packages to keep up with upstream releases, projects that no longer build with newer versions of those packages (in this case, armnn and tflite) also stop building. I am able to pin to an older tflite for now, but this will inevitably become a barrier to building armnn on up-to-date systems down the line.

For what it's worth, it looks like Arm NN already builds fine with TfLite v2.16.2.

Cheers, Jon

jonhoo commented 1 week ago

@Colm-in-Arm Did you intend to close this? I don't see any changes in the new release notes about tflite 2.17?

Colm-in-Arm commented 1 week ago

Hi Jon,

We have no plans to move to Tensorflow 2.17 so I don't see any need to make an addition to the release notes about this. I hope I've not missed something here.

Colm.