Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS build broken (Tensorflow dependency) #1352

Open
LDMFD opened this issue Jul 10, 2023 · 7 comments
Open

iOS build broken (Tensorflow dependency) #1352

LDMFD opened this issue Jul 10, 2023 · 7 comments

Comments

@LDMFD
Copy link

LDMFD commented Jul 10, 2023

Building with python3 waf configure --cross-compile-ios --lightweight= --fft=ACCELERATE --build-static --ignore-algos=NNLSChroma

I needed to comment out two sections in types.h;

  1. Relating to string comparison;
  2. Relating to Tensor;
    • I needed to comment out:
      • #include <unsupported/Eigen/CXX11/Tensor>
      • The 6 or so Tensor types (starting from Alias for Eigen::Tensor.).

This is despite Tensor apparently being ignored; the build log gives:

- Essentia is configured without Tensorflow.
  The following algorithms will be ignored: ['TensorflowPredict', 'TensorflowPredictMusiCNN', 
'TensorflowPredictVGGish', 'TensorflowPredictTempoCNN', 'TensorflowPredictCREPE', 
'PitchCREPE', 'TempoCNN', 'TensorflowPredictEffnetDiscogs', 'TensorflowPredict2D', 'TensorflowPredictFSDSINet']

Is there any fix already present that I simply need to enable?

I'm building on MacOS Ventura 13.4, with Xcode 15.0 beta 2.

@LDMFD
Copy link
Author

LDMFD commented Jul 10, 2023

Update: as the Stackoverflow post hints at, switching the C++ dialect to gnu++14 (in Xcode) solves the problem for the string comparison function.

@palonso
Copy link
Contributor

palonso commented Jul 12, 2023

hi @LDMFD,
right, the Tensorflow-related algorithms are ignored by default, but we don't have a mechanism to prevent creating the Tensor types.

I can see that similar problems occur in OpenCV, and they now support deactivating the Eigen Tensors.

We could be interested in doing the same.

@LDMFD
Copy link
Author

LDMFD commented Jul 16, 2023

Hi @palonso thank you for the feedback. I hit this problem again after including essentiamath.h. What is the correct fix for iOS builds?

I built with --with-tensorflow but looking at the missing symbols, it seems Essentia depends on the full Tensorflow library, so:

  1. Are the Tensor-based features of Essentia available for mobile?
  2. Regardless of Tensorflow, is there a known build working for iOS? (if so, what am I missing)

I am looking for pitch detection primarily.

@LDMFD LDMFD changed the title iOS build appears to require commenting out Tensor and string comparison functions iOS build broken (Tensorflow dependency) Jul 16, 2023
@palonso
Copy link
Contributor

palonso commented Jul 17, 2023

@LDMFD,
Essentia only depends on TensorFlow when using the --with-tensorflow flag.
The purpose of TensorFlow is to use our Essentia Models, so for your use case, you can build Essentia without the flag.

Since tensor-based methods are only required when using these models, we could have a directive WITH_TENSORFLOW to skip tensor-based auxiliary methods and types when TensorFlow is not required.

For now, you can just comment out these methods in essentiamath.h and the types.

@LDMFD
Copy link
Author

LDMFD commented Jul 18, 2023

Appreciate the pointer - will give this a try.

@ashayk
Copy link

ashayk commented Sep 23, 2023

I'm following up here in hopes this will be useful for others. From what I can tell, Essentia with tensorflow (needed for TemopCNN) is simply incompatible with iOS. TensorFlowLite (the only supported target for iOS), has a different set of interfaces to what the TempoCNN components in Essentia use. Including the TensorFlow header path in an XCode project results in undefined symbol compiler errors.

_TF_AllocateTensor, referenced from:
essentia::standard::TensorflowPredict::configure() in libessentia.a[arm64]167
.
.
.

It would have been useful to know about this incompatibility before wasting a day trying to make it work. Hopefully this will be useful for others.

@dbogdanov
Copy link
Member

@ashayk We apologize for any confusion. Unfortunately, adding TensorFlowLite support is out of scope at the moment. We added a clarification to the FAQ (4c48bb1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants