• Home
Name Date Size #Lines LOC

..--

g3doc/03-May-2024-2,0851,775

hlo/03-May-2024-5,0354,138

lite/03-May-2024-97,55076,926

python/03-May-2024-1,099773

quantization/tensorflow/03-May-2024-15,03611,548

tensorflow/03-May-2024-169,783131,554

tf2xla/03-May-2024-14569

tfjs/03-May-2024-1,6701,210

tfr/03-May-2024-10,5277,848

tfrt/03-May-2024-52,08039,057

tools/kernel_gen/03-May-2024-9,8307,546

tosa/03-May-2024-20,70414,615

utils/03-May-2024-258130

xla/03-May-2024-49,09438,318

BUILDD03-May-20249 KiB269248

README.mdD03-May-20241.6 KiB4635

glob_lit_test.bzlD03-May-20244.3 KiB117104

init_mlir.ccD03-May-20242 KiB6237

init_mlir.hD03-May-20241.4 KiB4013

mlir_graph_optimization_pass.ccD03-May-202417.2 KiB441318

mlir_graph_optimization_pass.hD03-May-20248 KiB213113

mlir_graph_optimization_pass_registration.ccD03-May-20241.2 KiB3110

mlir_graph_optimization_pass_test.ccD03-May-20248.5 KiB220161

op_or_arg_name_mapper.ccD03-May-20245.3 KiB14190

op_or_arg_name_mapper.hD03-May-20243.6 KiB10341

runlit.cfg.pyD03-May-20243.2 KiB8242

runlit.site.cfg.pyD03-May-20243.1 KiB8151

tf_mlir_opt_main.ccD03-May-20243.8 KiB7757

tf_mlir_reduce_main.ccD03-May-20243.3 KiB8255

tf_mlir_translate_main.ccD03-May-20246.9 KiB177129

README.md

1# MLIR dialects and utilities for TensorFlow, TensorFlow Lite and XLA.
2
3This module contains the MLIR
4([Multi-Level Intermediate Representation](https://mlir.llvm.org))
5dialects and utilities for
6
71. TensorFlow
82. XLA
93. TF Lite
10
11See [MLIR's website](https://mlir.llvm.org) for complete documentation.
12
13## Getting started
14
15Building dialects and utilities here follow the standard approach using
16`bazel` as the rest of TensorFlow.
17
18### Using local LLVM repo
19
20To develop across MLIR core and TensorFlow, it is useful to override the repo
21to use a local version instead of fetching from head. This can be achieved by
22setting up your local repository for Bazel build. For this you will need a
23temporary directory that will be "overlaid" with you LLVM source directory and
24the Bazel files:
25
26```sh
27LLVM_SRC=... # this the path to the LLVM local source directory you intend to use.
28LLVM_BAZEL_OVERLAY=${LLVM_SRC}/bazel # Note: this can be anywhere
29mkdir -p ${LLVM_BAZEL_OVERLAY}
30# This will symlink your LLVM sources with the BUILD files to be usable by Bazel.
31python ${LLVM_SRC}/utils/bazel/overlay_directories.py \
32    --src ${LLVM_SRC} \
33    --overlay ${LLVM_SRC}/utils/bazel/llvm-project-overlay/ \
34    --target ${LLVM_BAZEL_OVERLAY}
35touch ${LLVM_BAZEL_OVERLAY}/BUILD.bazel ${LLVM_BAZEL_OVERLAY}/WORKSPACE
36# The complete list is "AArch64", "AMDGPU", "ARM", "NVPTX", "PowerPC", "RISCV", "SystemZ", "X86"
37echo 'llvm_targets = ["X86"]' > ${LLVM_BAZEL_OVERLAY}/llvm/targets.bzl
38```
39
40You can then use this overlay to build TensorFlow:
41
42```
43bazel build --override_repository=llvm-project=$LLVM_BAZEL_OVERLAY \
44  -c opt tensorflow/compiler/mlir:tf-opt
45```
46