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

Int incompatibility error on building TensorFlowLiteC framework #48464

Closed
mspnr opened this issue Apr 11, 2021 · 9 comments
Closed

Int incompatibility error on building TensorFlowLiteC framework #48464

mspnr opened this issue Apr 11, 2021 · 9 comments
Assignees
Labels
comp:lite-xnnpack TensorFlow Lite XNNPack related issues type:build/install Build and install issues

Comments

@mspnr
Copy link

mspnr commented Apr 11, 2021

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS 11.2.2
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: n/a
  • TensorFlow installed from (source or binary): github repository
  • TensorFlow version: github repository
  • Python version: 3.8.2
  • Installed using virtualenv? pip? conda?: directly from standard terminal
  • Bazel version (if compiling from source): 3.7.2
  • GCC/Compiler version (if compiling from source): Apple clang version 12.0.0 (clang-1200.0.32.29)
  • CUDA/cuDNN version: n/a
  • GPU model and memory: n/a

Problem description

I tried to build TensorFlow Lite as suggested here:
Build TensorFlowLiteC dynamic framework (recommended)
https://www.tensorflow.org/lite/guide/build_ios#build_tensorflowlitec_dynamic_framework_recommended
and ended up with int vs int32 incompatibility error

Steps

  1. Install Bazel
  2. Clone TensoFlow repository from github
  3. Run .configure
  4. Start bazel build

The build is ending up with error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'

I tried on two different MacBooks with M1 and Intel chips.

The issues seem to come from here:
https://github.com/google/XNNPACK/issues?q=is%3Aissue+int
but I can't find any appropriate one.

Could you suggest why it is happened and how the TensorFlowLiteC dynamic framework can be built?

Logs

Log part:

external/XNNPACK/src/qs8-gemm/gen/1x8c4-minmax-neondot.c:63:18: error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'
vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb0123x0123, va0x01234567, 0);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Full log:
tflite_install.log

@abattery
Copy link
Contributor

@Maratyszcza @multiverse-tf could you take a look at this?

@abattery abattery added the comp:lite-xnnpack TensorFlow Lite XNNPack related issues label Apr 11, 2021
@multiverse-tf
Copy link
Contributor

multiverse-tf commented Apr 12, 2021

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS 11.2.2
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: n/a
  • TensorFlow installed from (source or binary): github repository
  • TensorFlow version: github repository
  • Python version: 3.8.2
  • Installed using virtualenv? pip? conda?: directly from standard terminal
  • Bazel version (if compiling from source): 3.7.2
  • GCC/Compiler version (if compiling from source): Apple clang version 12.0.0 (clang-1200.0.32.29)
  • CUDA/cuDNN version: n/a
  • GPU model and memory: n/a

Problem description

I tried to build TensorFlow Lite as suggested here:
Build TensorFlowLiteC dynamic framework (recommended)
https://www.tensorflow.org/lite/guide/build_ios#build_tensorflowlitec_dynamic_framework_recommended
and ended up with int vs int32 incompatibility error

Steps

  1. Install Bazel
  2. Clone TensoFlow repository from github
  3. Run .configure
  4. Start bazel build

The build is ending up with error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'

I tried on two different MacBooks with M1 and Intel chips.

The issues seem to come from here:
https://github.com/google/XNNPACK/issues?q=is%3Aissue+int
but I can't find any appropriate one.

Could you suggest why it is happened and how the TensorFlowLiteC dynamic framework can be built?

Logs

Log part:

external/XNNPACK/src/qs8-gemm/gen/1x8c4-minmax-neondot.c:63:18: error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'
vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb0123x0123, va0x01234567, 0);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Full log:
tflite_install.log

According to this comment, the issue should have been fixed on the XNNPACK side by this commit google/XNNPACK@60fc613. Could you help with the verification? Thx!

Btw, you need to change https://github.com/tensorflow/tensorflow/blob/master/tensorflow/workspace2.bzl to update the XNNPACK to the proper commit for the testing.

@saikumarchalla saikumarchalla removed their assignment Apr 12, 2021
@mspnr
Copy link
Author

mspnr commented Apr 12, 2021

@multiverse-tf thank you for the tip with updating of workspace2.bzl. I am compiling tensorflow for the first time, so it was not so obvious for me.

So what I did:

  1. I retrieved the commit ID from google/XNNPACK@60fc613
  2. It is 60fc61373f21f0ad3164cc719de464f4b787dc04
  3. I replaced commit ID in 3 places: strip_prefix and two urls
  4. I got and updated sha256 based on the second URL

The final part looks like this, starting from line 121:

# To update any of the dependencies bellow:
# a) update URL and strip_prefix to the new git commit hash
# b) get the sha256 hash of the commit by running:
#    curl -L <url> | sha256sum
# and update the sha256 with the result.
tf_http_archive(
    name = "XNNPACK",
    sha256 = "27736d765efbac5a8077862515b7212bd9a5cfa281ab06f4c0a27c3fc445c58e",
    strip_prefix = "XNNPACK-60fc61373f21f0ad3164cc719de464f4b787dc04",
    urls = [
        "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/XNNPACK/archive/60fc61373f21f0ad3164cc719de464f4b787dc04.zip",
        "https://github.com/google/XNNPACK/archive/60fc61373f21f0ad3164cc719de464f4b787dc04.zip",
    ],
)

I also noticed, that from these two URLs only the second one is operational.
For the first URL I see:
Screenshot 2021-04-12 at 19 09 08

Before starting the build I also cleared the folder /private/var/tmp/_bazel_user

Anyway the build failed with almost the same results.

Here is the warning regarding missing commit:
Screenshot 2021-04-12 at 19 39 16

Full log:
tflite_install2.log

Do you have any advice how to proceed further?

@Maratyszcza
Copy link
Contributor

The error is due to compiler lacking vdotq_lane_s32 instructions. If you're building for iOS, please try a newer version of XCode. If you're building for Android, please try Android NDK r19 or later.

@mspnr
Copy link
Author

mspnr commented Apr 12, 2021

@Maratyszcza thank you for the advice!

I am building iOS version and currently using the latest stable version of XCode:

% xcodebuild -version
Xcode 12.4
Build version 12D4e

Screenshot 2021-04-12 at 22 41 45

https://en.wikipedia.org/wiki/Xcode
Screenshot 2021-04-12 at 22 39 52

Would you suggest to use beta 12.5 beta 3 (12E5244e)?

For me it is also OK to not have the latest version of TensorFlow. What do you think if I get the previous release, could it be built using the stable version of XCode? Do you have any certain release in mind?

@Maratyszcza
Copy link
Contributor

From the report in google/XNNPACK#1402 it looks like Apple toolchain for AArch32 doesn't support neon-dot intrinsics at all. I'm working on removing these microkernels from iOS ARMv7 builds.

@Maratyszcza
Copy link
Contributor

99db613 is supposed to fix this issue

@mspnr
Copy link
Author

mspnr commented Apr 14, 2021

@Maratyszcza thank you!

I made git checkout 99db61328e4d63ba7c1a35827290b504bebcccb6 and then repeated the steps as described on the page.

bazel build --config=ios_fat -c opt \
  //tensorflow/lite/ios:TensorFlowLiteC_framework

The build has been completed without errors.

@mspnr mspnr closed this as completed Jun 6, 2021
@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:lite-xnnpack TensorFlow Lite XNNPack related issues type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

5 participants