Skip to content

Instantly share code, notes, and snippets.

@carlthome
Last active October 11, 2022 16:14
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save carlthome/6ae8a570e21069c60708017e3f96c9fd to your computer and use it in GitHub Desktop.
Save carlthome/6ae8a570e21069c60708017e3f96c9fd to your computer and use it in GitHub Desktop.
Example of how to use XLA AOT via tfcompile to build a Keras model into a shared library.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@powderluv
Copy link

did you solve the error ?

@matt3oIta
Copy link

no. are you experiencing the same?

@snowcrumble
Copy link

I am trying to use XLA compiler from Tensorflow following your jupyter example

During execution of bazel build I always end up on the following build error:

error: Could not find include file 'tensorflow/compiler/mlir/xla/ir/hlo_ops_base.td' include "tensorflow/compiler/mlir/xla/ir/hlo_ops_base.td" ^ external/org_tensorflow/tensorflow/compiler/mlir/xla/ir/hlo_ops.td:22:9: error: Unexpected input at top level include "tensorflow/compiler/mlir/xla/ir/hlo_ops_base.td"

> ERROR: /home/ubuntu/.cache/bazel/_bazel_ubuntu/e5cce820cc082410b4fcc604db349066/external/org_tensorflow/tensorflow/compiler/mlir/xla/BUILD:465:1: Executing genrule @org_tensorflow//tensorflow/compiler/mlir/xla:operator_writer_inc failed (Exit 1)
[6,144 / 7,191] 3 actions running
    @org_tensorflow//tensorflow/compiler/xla/client:global_data; 4s local
    @org_tensorflow//tensorflow/core/kernels/tensor_forest:resources; 1s local
    ...//tensorflow/core/kernels:eigen_contraction_kernel_with_mkl; 1s local
external/org_tensorflow/tensorflow/compiler/mlir/xla/ir/hlo_ops.td:22:9: error: Could not find include file 'tensorflow/compiler/mlir/xla/ir/hlo_ops_base.td'
include "tensorflow/compiler/mlir/xla/ir/hlo_ops_base.td"
        ^
external/org_tensorflow/tensorflow/compiler/mlir/xla/ir/hlo_ops.td:22:9: error: Unexpected input at top level
include "tensorflow/compiler/mlir/xla/ir/hlo_ops_base.td"
        ^
[6,144 / 7,191] 3 actions running
    @org_tensorflow//tensorflow/compiler/xla/client:global_data; 4s local
    @org_tensorflow//tensorflow/core/kernels/tensor_forest:resources; 1s local
    ...//tensorflow/core/kernels:eigen_contraction_kernel_with_mkl; 1s local
Target @org_tensorflow//:graph failed to build
[6,147 / 7,191] checking cached actions
Use --verbose_failures to see the command lines of failed build steps.
[6,147 / 7,191] checking cached actions
INFO: Elapsed time: 7903.567s, Critical Path: 204.12s
[6,147 / 7,191] checking cached actions
INFO: 5961 processes: 5961 local.
[6,147 / 7,191] checking cached actions
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

So, it does not find the hlo_ops_base.td file, which of course is present in the path (I checked it)

The first time I have tried this, it worked like a charm.

Afterwards I have executed it again on different machines (also perfect clean VMs on different platforms), but always had the same issue.

I am using:

  • bazel 1.1.0,
  • tensorflow 1.14 (cpu),
  • protobuf 3.0.0,
  • python 2.7

Does anyone have any clue on how to solve this? I have tried to search it online and it seems no one else is having this issue...

Thanks, Matteo

same

@reza-ebrahimi
Copy link

Model => 150 ms ± 199 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
XLA binary => 191 ms ± 604 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

Why XLA compiled binary is slower than the model itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment