2020-08-06 14:27:48 +08:00
|
|
|
#
|
|
|
|
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
include_directories(BEFORE
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
|
|
|
set(LLVM_TARGET_DEFINITIONS lower_complex_patterns.td)
|
|
|
|
mlir_tablegen(generated_lower_complex.inc -gen-rewriters)
|
|
|
|
add_public_tablegen_target(MLIRMhloLowerComplexIncGen)
|
|
|
|
|
|
|
|
set(LLVM_TARGET_DEFINITIONS legalize_to_standard_patterns.td)
|
|
|
|
mlir_tablegen(generated_legalize_to_standard.inc -gen-rewriters)
|
|
|
|
add_public_tablegen_target(MLIRMhloLegalizeToStandardIncGen)
|
|
|
|
|
2020-09-14 17:30:26 +08:00
|
|
|
set(LLVM_TARGET_DEFINITIONS chlo_legalize_to_hlo_patterns.td)
|
|
|
|
mlir_tablegen(generated_chlo_legalize_to_hlo.inc -gen-rewriters)
|
|
|
|
add_public_tablegen_target(MLIRChloLegalizeToHloIncGen)
|
|
|
|
|
2020-08-06 14:27:48 +08:00
|
|
|
|
|
|
|
add_mlir_library(ChloPasses
|
|
|
|
chlo_legalize_to_hlo.cc
|
|
|
|
chlo_legalize_to_hlo_pass.cc
|
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
MLIRhlo_opsIncGen
|
2020-09-14 17:30:26 +08:00
|
|
|
MLIRChloLegalizeToHloIncGen
|
2020-08-06 14:27:48 +08:00
|
|
|
|
|
|
|
LINK_COMPONENTS
|
|
|
|
Core
|
|
|
|
|
|
|
|
LINK_LIBS PUBLIC
|
|
|
|
ChloDialect
|
|
|
|
MLIRIR
|
|
|
|
MLIRPass
|
|
|
|
)
|
|
|
|
|
|
|
|
add_mlir_library(MhloPasses
|
2021-06-08 16:50:02 +08:00
|
|
|
broadcast_propagation.cc
|
2020-08-06 14:27:48 +08:00
|
|
|
legalize_gather_to_torch_index_select.cc
|
2020-09-24 02:53:08 +08:00
|
|
|
legalize_trigonometric_to_approximation.cc
|
2020-08-06 14:27:48 +08:00
|
|
|
lower_complex.cc
|
|
|
|
lower_complex_patterns.td
|
|
|
|
lower_general_dot.cc
|
|
|
|
materialize_broadcasts.cc
|
|
|
|
materialize_broadcasts_pass.cc
|
|
|
|
mhlo_fusion.cc
|
|
|
|
optimize_mhlo.cc
|
|
|
|
optimize_mhlo_pass.cc
|
2021-05-12 18:45:09 +08:00
|
|
|
rank_specialization.cc
|
2020-08-06 14:27:48 +08:00
|
|
|
sink_constants_to_control_flow.cc
|
|
|
|
test_infer_shaped_type_pass.cc
|
|
|
|
unfuse_batch_norm.cc
|
|
|
|
unfuse_batch_norm_pass.cc
|
|
|
|
|
|
|
|
DEPENDS
|
2021-06-15 08:01:34 +08:00
|
|
|
MLIRDiscRalPassIncGen
|
2020-08-06 14:27:48 +08:00
|
|
|
MLIRhlo_opsIncGen
|
|
|
|
MLIRMhloLowerComplexIncGen
|
2020-11-04 03:18:14 +08:00
|
|
|
MLIRMhloPassIncGen
|
2020-08-06 14:27:48 +08:00
|
|
|
|
|
|
|
LINK_COMPONENTS
|
|
|
|
Core
|
|
|
|
|
|
|
|
LINK_LIBS PUBLIC
|
|
|
|
MLIRIR
|
|
|
|
MLIRMhloUtils
|
|
|
|
MLIRPass
|
|
|
|
MLIRTransformUtils
|
|
|
|
)
|
|
|
|
|
|
|
|
add_mlir_library(MhloToLhloConversion
|
|
|
|
hlo_legalize_to_lhlo.cc
|
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
MLIRhlo_opsIncGen
|
|
|
|
MLIRlhlo_opsIncGen
|
|
|
|
|
|
|
|
LINK_COMPONENTS
|
|
|
|
Core
|
|
|
|
|
|
|
|
LINK_LIBS PUBLIC
|
|
|
|
MhloDialect
|
|
|
|
LmhloDialect
|
|
|
|
MLIRIR
|
|
|
|
MLIRPass
|
2021-02-13 00:30:51 +08:00
|
|
|
MLIRMath
|
2020-08-06 14:27:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
add_mlir_library(MhloToStandard
|
|
|
|
legalize_control_flow.cc
|
|
|
|
legalize_to_standard.cc
|
2020-08-29 06:10:56 +08:00
|
|
|
mhlo_control_flow_to_scf.cc
|
2020-08-06 14:27:48 +08:00
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
MLIRhlo_opsIncGen
|
|
|
|
MLIRlhlo_opsIncGen
|
|
|
|
MLIRMhloLegalizeToStandardIncGen
|
|
|
|
|
|
|
|
LINK_COMPONENTS
|
|
|
|
Core
|
|
|
|
|
|
|
|
LINK_LIBS PUBLIC
|
|
|
|
MLIRIR
|
|
|
|
MLIRPass
|
2020-12-17 16:55:03 +08:00
|
|
|
MLIRTensor
|
2020-08-06 14:27:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
add_mlir_library(MhloLhloToLinalg
|
|
|
|
legalize_to_linalg.cc
|
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
MLIRhlo_opsIncGen
|
|
|
|
MLIRlhlo_opsIncGen
|
|
|
|
|
|
|
|
LINK_COMPONENTS
|
|
|
|
Core
|
|
|
|
|
|
|
|
LINK_LIBS PUBLIC
|
|
|
|
MhloDialect
|
2021-01-22 04:40:46 +08:00
|
|
|
MLIRComplex
|
2020-08-06 14:27:48 +08:00
|
|
|
MLIRIR
|
|
|
|
MLIRPass
|
|
|
|
)
|
|
|
|
|
|
|
|
add_mlir_library(LmhloPasses
|
2021-06-17 00:50:41 +08:00
|
|
|
fusion_utils.cc
|
2021-06-02 07:27:07 +08:00
|
|
|
legalize_tensor_load_op.cc
|
2020-08-06 14:27:48 +08:00
|
|
|
lhlo_fuse_linalg.cc
|
2021-06-17 00:50:41 +08:00
|
|
|
lhlo_fusion.cc
|
2020-08-06 14:27:48 +08:00
|
|
|
lhlo_legalize_to_affine.cc
|
|
|
|
lhlo_legalize_to_gpu.cc
|
|
|
|
lhlo_legalize_to_parallel_loops.cc
|
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
MLIRlhlo_opsIncGen
|
|
|
|
|
|
|
|
LINK_COMPONENTS
|
|
|
|
Core
|
|
|
|
|
|
|
|
LINK_LIBS PUBLIC
|
|
|
|
LmhloDialect
|
|
|
|
MLIRIR
|
|
|
|
MLIRPass
|
|
|
|
)
|
|
|
|
|
PR #50191: [MLIR][DISC] Add RAL (Runtime abstraction layer) Dialect
Imported from GitHub PR https://github.com/tensorflow/tensorflow/pull/50191
DISC is a e2e flow, including both compiler side and runtime side. For
runtime side, we have different targeting environments (e.g. tensorflow,
pytorch, or sometimes even a standalone binary). In order to simplify
the design of the compiler side, we design a Runtime Abstraction Layer
(RAL) to sperate the compiler side and runtime side. Thus the compiler
side only need to target RAL itself and it is the responsibility of RAL
to handle the differences between different targeting environments.
One of the most important functions of RAL is to manage stateful
resources. To this end, it provides a context object, and hides all
stateful operations behind this context, thus the compiler side itself
doesn't need to care about the resource initialization. For example, a
kernel must be loaded before it can be launched on GPU. However, the
loading operation should only be taken once during the whole lifetime of
the context in order to achieve the best performance. Based on the
initialization-free interfaces provided by RAL, compiler side can focus
on its core optimization logic and lets the RAL to manage the resource
status.
The context mentioned above is passed as a parameter to the entry
function and all RAL APIs should always use the context as their first
argument. This CR also provides a pass to help to ensure this property.
The pass rewrites the entry function to make sure their first argument
is the context. For entry function, the pass also rewrites its inputs
and outputs. To be concrete, all the original inputs and outputs of the
entry function are received from and sent to RAL through a sequence of
RAL API calls correspondingly. The motivation behind this is to hide the
implementation details of I/Os. This design may also potentially enable
partial execution of the compiled module when some of the inputs are
ready.
Copybara import of the project:
--
c4f20a89aed71181e75bcc5265723b88bde23240 by Wenyi Zhao <reyizero@gmail.com>:
[MLIR][DISC] Add RAL (Runtime abstraction layer) Dialect
DISC is a e2e flow, including both compiler side and runtime side. For
runtime side, we have different targeting environments (e.g. tensorflow,
pytorch, or sometimes even a standalone binary). In order to simplify
the design of the compiler side, we design a Runtime Abstraction Layer
(RAL) to sperate the compiler side and runtime side. Thus the compiler
side only need to target RAL itself and it is the responsibility of RAL
to handle the differences between different targeting environments.
One of the most important functions of RAL is to manage stateful
resources. To this end, it provides a context object, and hides all
stateful operations behind this context, thus the compiler side itself
doesn't need to care about the resource initialization. For example, a
kernel must be loaded before it can be launched on GPU. However, the
loading operation should only be taken once during the whole lifetime of
the context in order to achieve the best performance. Based on the
initialization-free interfaces provided by RAL, compiler side can focus
on its core optimization logic and lets the RAL to manage the resource
status.
The context mentioned above is passed as a parameter to the entry
function and all RAL APIs should always use the context as their first
argument. This CR also provides a pass to help to ensure this property.
The pass rewrites the entry function to make sure their first argument
is the context. For entry function, the pass also rewrites its inputs
and outputs. To be concrete, all the original inputs and outputs of the
entry function are received from and sent to RAL through a sequence of
RAL API calls correspondingly. The motivation behind this is to hide the
implementation details of I/Os. This design may also potentially enable
partial execution of the compiled module when some of the inputs are
ready.
--
1991d4f80ab6087943956e1c0fec4940a22ab08d by Wenyi Zhao <reyizero@gmail.com>:
fix
PiperOrigin-RevId: 379317586
2021-06-15 02:26:41 +08:00
|
|
|
add_mlir_library(DiscRalPasses
|
|
|
|
ral_inject_execution_context.cc
|
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
MLIRdisc_ral_opsIncGen
|
|
|
|
MLIRDiscRalPassIncGen
|
|
|
|
|
|
|
|
LINK_COMPONENTS
|
|
|
|
Core
|
|
|
|
|
|
|
|
LINK_LIBS PUBLIC
|
|
|
|
DiscRalDialect
|
|
|
|
MLIRIR
|
|
|
|
MLIRPass
|
|
|
|
)
|
|
|
|
|
2020-08-06 14:27:48 +08:00
|
|
|
add_library(AllMhloPasses INTERFACE)
|
|
|
|
target_link_libraries(AllMhloPasses INTERFACE
|
|
|
|
ChloPasses
|
PR #50191: [MLIR][DISC] Add RAL (Runtime abstraction layer) Dialect
Imported from GitHub PR https://github.com/tensorflow/tensorflow/pull/50191
DISC is a e2e flow, including both compiler side and runtime side. For
runtime side, we have different targeting environments (e.g. tensorflow,
pytorch, or sometimes even a standalone binary). In order to simplify
the design of the compiler side, we design a Runtime Abstraction Layer
(RAL) to sperate the compiler side and runtime side. Thus the compiler
side only need to target RAL itself and it is the responsibility of RAL
to handle the differences between different targeting environments.
One of the most important functions of RAL is to manage stateful
resources. To this end, it provides a context object, and hides all
stateful operations behind this context, thus the compiler side itself
doesn't need to care about the resource initialization. For example, a
kernel must be loaded before it can be launched on GPU. However, the
loading operation should only be taken once during the whole lifetime of
the context in order to achieve the best performance. Based on the
initialization-free interfaces provided by RAL, compiler side can focus
on its core optimization logic and lets the RAL to manage the resource
status.
The context mentioned above is passed as a parameter to the entry
function and all RAL APIs should always use the context as their first
argument. This CR also provides a pass to help to ensure this property.
The pass rewrites the entry function to make sure their first argument
is the context. For entry function, the pass also rewrites its inputs
and outputs. To be concrete, all the original inputs and outputs of the
entry function are received from and sent to RAL through a sequence of
RAL API calls correspondingly. The motivation behind this is to hide the
implementation details of I/Os. This design may also potentially enable
partial execution of the compiled module when some of the inputs are
ready.
Copybara import of the project:
--
c4f20a89aed71181e75bcc5265723b88bde23240 by Wenyi Zhao <reyizero@gmail.com>:
[MLIR][DISC] Add RAL (Runtime abstraction layer) Dialect
DISC is a e2e flow, including both compiler side and runtime side. For
runtime side, we have different targeting environments (e.g. tensorflow,
pytorch, or sometimes even a standalone binary). In order to simplify
the design of the compiler side, we design a Runtime Abstraction Layer
(RAL) to sperate the compiler side and runtime side. Thus the compiler
side only need to target RAL itself and it is the responsibility of RAL
to handle the differences between different targeting environments.
One of the most important functions of RAL is to manage stateful
resources. To this end, it provides a context object, and hides all
stateful operations behind this context, thus the compiler side itself
doesn't need to care about the resource initialization. For example, a
kernel must be loaded before it can be launched on GPU. However, the
loading operation should only be taken once during the whole lifetime of
the context in order to achieve the best performance. Based on the
initialization-free interfaces provided by RAL, compiler side can focus
on its core optimization logic and lets the RAL to manage the resource
status.
The context mentioned above is passed as a parameter to the entry
function and all RAL APIs should always use the context as their first
argument. This CR also provides a pass to help to ensure this property.
The pass rewrites the entry function to make sure their first argument
is the context. For entry function, the pass also rewrites its inputs
and outputs. To be concrete, all the original inputs and outputs of the
entry function are received from and sent to RAL through a sequence of
RAL API calls correspondingly. The motivation behind this is to hide the
implementation details of I/Os. This design may also potentially enable
partial execution of the compiled module when some of the inputs are
ready.
--
1991d4f80ab6087943956e1c0fec4940a22ab08d by Wenyi Zhao <reyizero@gmail.com>:
fix
PiperOrigin-RevId: 379317586
2021-06-15 02:26:41 +08:00
|
|
|
DiscRalPasses
|
2020-08-06 14:27:48 +08:00
|
|
|
MhloPasses
|
|
|
|
MhloToLhloConversion
|
|
|
|
MhloToStandard
|
|
|
|
MhloLhloToLinalg
|
|
|
|
LmhloPasses
|
|
|
|
)
|