Commit Graph

13 Commits

Author SHA1 Message Date
colin.liang 95fc37ffa8 add integer attribute convert 2021-08-11 10:46:07 +08:00
colin.liang e62fa9311f add tensor from host to jit runner,and get output 2021-07-13 20:11:53 +08:00
colin.liang 62e7b883c7 add cpu runner in llvm 2021-07-12 21:03:29 +08:00
Wenyi Zhao 23ebbb28d1 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-14 11:27:43 -07:00
Adrian Kuegel 6388e8d9ee mlir-hlo-opt: set preloadDialectsInContext to false.
This requires specifying dependent dialects in several passes.

PiperOrigin-RevId: 365758084
2021-03-30 01:07:14 -07:00
Mehdi Amini 98debb127d Update Tensorflow to prepare for changing the default value of `preloadDialectsInContext`
This makes tf-opt more strict on the dialect dependencies, and immediately reduces
the number of dialects loaded.
The canonicalization of TensorFlow graphs showed on the profile that Linalg pattern
were dominated the time, which is unexpected since Linalg is not even intended to be
used there.

PiperOrigin-RevId: 364087027
2021-03-20 11:01:55 -07:00
Rahul Joshi f6b4e6758a Add GPU specific LMHLO level ops
- Introduce operations in a new lmhlo_gpu dialect that map to GPU library function calls
  in the XLA:GPU backend.
- Add basic unit tests as well.

PiperOrigin-RevId: 337132166
2020-10-14 11:23:55 -07:00
Mehdi Amini f39466cc2d Add explicit dialect registration for mlir-hlo-opt
This is fixing the build after upstream changes.

PiperOrigin-RevId: 327738263
2020-08-20 18:51:06 -07:00
A. Unique TensorFlower b4726e6e59 Integrate LLVM at llvm/llvm-project@f9dc2b7079
Updates LLVM usage to match
[f9dc2b707935](https://github.com/llvm/llvm-project/commit/f9dc2b707935)

PiperOrigin-RevId: 327538369
2020-08-19 17:18:36 -07:00
Marius Brehler 98a8b2c0cf PR #42473: Check libraries linked into mlir-hlo-opt
Imported from GitHub PR https://github.com/tensorflow/tensorflow/pull/42473

Adds a call to mlir_check_all_link_libraries() to check all libraries
linked into mlir-hlo-opt.
Copybara import of the project:

--
0bf620f5f2708e730689eab8a5512fb00eaf1706 by Marius Brehler <marius.brehler@iml.fraunhofer.de>:

Check libraries linked into mlir-hlo-opt

Adds a call to mlir_check_all_link_libraries() to check all libraries
linked into mlir-hlo-opt.

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/tensorflow/pull/42473 from marbre:check_link_libraries 0bf620f5f2708e730689eab8a5512fb00eaf1706
PiperOrigin-RevId: 327463012
2020-08-19 10:44:00 -07:00
Jacques Pienaar 8712cbae75 Add missing command line option registrations
PiperOrigin-RevId: 326773738
2020-08-14 20:08:06 -07:00
Mehdi Amini 701312720c Add CMake files and lit configurations, enough for `ninja check-mlir-hlo` to pass on all the tests
PiperOrigin-RevId: 325172984
2020-08-07 22:14:34 -07:00
Mehdi Amini cd01bb4c4e More cleanup in mlir-hlo to prepare for the standalone build
Shuffle files around, use TableGen to register passes, and introduce
a `mlir-hlo-opt.cpp` file to hold the main entry point of the -opt tool
and stop relying on static registration for dialect/passes.

PiperOrigin-RevId: 323674455
2020-08-03 19:28:00 -07:00