tree: e10485d5650f68d70315eae0e5ec2cab3fc540b2 [path history] [tgz]
  1. g3doc/
  2. lite/
  3. python/
  4. quantization/
  5. tensorflow/
  6. tf2xla/
  7. tfr/
  8. tfrt/
  9. tools/
  10. tosa/
  11. utils/
  12. xla/
  13. BUILD
  14. glob_lit_test.bzl
  15. init_mlir.cc
  16. init_mlir.h
  17. mlir_graph_optimization_pass.cc
  18. mlir_graph_optimization_pass.h
  19. mlir_graph_optimization_pass_registration.cc
  20. mlir_graph_optimization_pass_test.cc
  21. op_or_arg_name_mapper.cc
  22. op_or_arg_name_mapper.h
  23. README.md
  24. runlit.cfg.py
  25. runlit.site.cfg.py
  26. tf_mlir_opt_main.cc
  27. tf_mlir_reduce_main.cc
  28. tf_mlir_translate_main.cc
tensorflow/compiler/mlir/README.md

MLIR dialects and utilities for TensorFlow, TensorFlow Lite and XLA.

This module contains the MLIR (Multi-Level Intermediate Representation) dialects and utilities for

  1. TensorFlow
  2. XLA
  3. TF Lite

See MLIR's website for complete documentation.

Getting started

Building dialects and utilities here follow the standard approach using bazel as the rest of TensorFlow.

Using local LLVM repo

To develop across MLIR core and TensorFlow, it is useful to override the repo to use a local version instead of fetching from head. This can be achieved by setting up your local repository for Bazel build. For this you will need a temporary directory that will be “overlaid” with you LLVM source directory and the Bazel files:

LLVM_SRC=... # this the path to the LLVM local source directory you intend to use.
LLVM_BAZEL_OVERLAY=${LLVM_SRC}/bazel # Note: this can be anywhere
mkdir -p ${LLVM_BAZEL_OVERLAY}
# This will symlink your LLVM sources with the BUILD files to be usable by Bazel.
python ${LLVM_SRC}/utils/bazel/overlay_directories.py \
    --src ${LLVM_SRC} \
    --overlay ${LLVM_SRC}/utils/bazel/llvm-project-overlay/ \
    --target ${LLVM_BAZEL_OVERLAY}
touch ${LLVM_BAZEL_OVERLAY}/BUILD.bazel ${LLVM_BAZEL_OVERLAY}/WORKSPACE
# The complete list is "AArch64", "AMDGPU", "ARM", "NVPTX", "PowerPC", "RISCV", "SystemZ", "X86"
echo 'llvm_targets = ["X86"]' > ${LLVM_BAZEL_OVERLAY}/llvm/targets.bzl

You can then use this overlay to build TensorFlow:

bazel build --override_repository=llvm-project=$LLVM_BAZEL_OVERLAY \
  -c opt tensorflow/compiler/mlir:tf-opt