mirror of https://github.com/llvm/torch-mlir
[torch-mlir earthmoving (2/N)] Python code movement.
This moves the bulk of the Python code (including the Torch interop) from `frontends/pytorch` into `torch-mlir/TorchPlugin`. This also required reconciling a bunch of other Python-related stuff, like the `torch` dialects. As I did this, it was simpler to just remove all the old numpy/basicpy stuff because we were going to delete it anyway and it was faster than debugging an intermediate state that would only last O(days) anyway. torch-mlir has two top-level python packages (built into the `python_packages` directory): - `torch_mlir_dialects`: `torch` dialect Python bindings (does not depend on PyTorch). This also involves building the aggregate CAPI for `torch-mlir`. - `torch_mlir`: bindings to the part of the code that links against PyTorch (or C++ code that transitively does). Additionally, there remain two more Python packages in npcomp (but outside `torch-mlir`): - `npcomp_torch`: Contains the e2e test framework and testing configs that plug into RefBackend and IREE. - `npcomp_core`: Contains the low-level interfaces to RefBackend and IREE that `npcomp_torch` uses, along with its own `MLIR_PYTHON_PACKAGE_PREFIX=npcomp.` aggregation of the core MLIR python bindings. (all other functionality has been stripped out) After all the basicpy/numpy deletions, the `npcomp` C++ code is now very tiny. It basically just contains RefBackend and the `TorchConversion` dialect/passes (e.g. `TorchToLinalg.cpp`). Correspondingly, there are now 4 main testing targets paralleling the Python layering (which is reflective of the deeper underlying dependency structure) - `check-torch-mlir`: checks the `torch-mlir` pure MLIR C++ code. - `check-torch-mlir-plugin`: checks the code in `TorchPlugin` (e.g. TorchScript import) - `check-frontends-pytorch`: Checks the little code we have in `frontends/pytorch` -- mainly things related to the e2e framework itself. - `check-npcomp`: Checks the pure MLIR C++ code inside npcomp. There is a target `check-npcomp-all` that runs all of them. The `torch-mlir/build_standalone.sh` script does a standalone build of `torch-mlir`. The e2e tests (`tools/torchscript_e2e_test.sh`) are working too. The update_torch_ods script now lives in `torch-mlir/build_tools/update_torch_ods.sh` and expects a standalone build. This change also required a fix upstream related to cross-shlib Python dependencies, so we also update llvm-project to 8dca953dd39c0cd8c80decbeb38753f58a4de580 to get https://reviews.llvm.org/D109776 (no other fixes were needed for the integrate, thankfully). This completes most of the large source code changes. Next will be bringing the CI/packaging/examples back to life.pull/306/head
parent
28a7738189
commit
b6be96d722
|
@ -43,8 +43,7 @@ jobs:
|
|||
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
|
||||
-DPython3_EXECUTABLE=$(which python) \
|
||||
-DLLVM_ENABLE_ASSERTIONS=ON \
|
||||
-DLLVM_TARGETS_TO_BUILD=host \
|
||||
-DNPCOMP_ENABLE_PYTORCH=ON
|
||||
-DLLVM_TARGETS_TO_BUILD=host
|
||||
ninja
|
||||
ninja check-npcomp check-frontends-pytorch
|
||||
- name: Refbackend integration tests
|
||||
|
|
|
@ -25,7 +25,6 @@ set(NPCOMP_MINIMUM_PYTHON_VERSION 3.6)
|
|||
option(NPCOMP_ENABLE_IREE "Enables the IREE backend (must configure location via IREE_DIR)." OFF)
|
||||
option(NPCOMP_ENABLE_REFJIT "Enables the reference JIT backend." ON)
|
||||
set(NPCOMP_IREE_BUILDDIR "../iree-build" CACHE STRING "If building IREE, then setting this elects to build from a source directory (versus installed package)")
|
||||
option(NPCOMP_ENABLE_PYTORCH "Enables PyTorch integration." OFF)
|
||||
|
||||
# Turn on -gsplit-dwarf if requested in debug builds.
|
||||
if (NPCOMP_USE_SPLIT_DWARF AND
|
||||
|
@ -50,6 +49,15 @@ if(MSVC)
|
|||
)
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Directory setup
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
set(MLIR_NPCOMP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(MLIR_NPCOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(MLIR_NPCOMP_PYTHON_PACKAGES_DIR ${CMAKE_CURRENT_BINARY_DIR}/python_packages)
|
||||
set(TORCH_MLIR_PYTHON_PACKAGES_DIR "${MLIR_NPCOMP_PYTHON_PACKAGES_DIR}")
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
# If we are not building as a part of LLVM, build NPCOMP as a standalone
|
||||
# project, including LLVM as a subdirectory. This gives us the most control
|
||||
|
@ -235,17 +243,9 @@ if(NPCOMP_ENABLE_IREE)
|
|||
symlink_iree(bindings/python/pyiree/rt python/pyiree/rt)
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Directory setup
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
set(MLIR_NPCOMP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(MLIR_NPCOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(MLIR_NPCOMP_PYTHON_PACKAGES_DIR ${CMAKE_CURRENT_BINARY_DIR}/python_packages)
|
||||
|
||||
add_custom_target(check-npcomp)
|
||||
add_custom_target(check-npcomp-all)
|
||||
add_dependencies(check-npcomp-all check-npcomp)
|
||||
add_dependencies(check-npcomp-all check-npcomp check-frontends-pytorch check-torch-mlir check-torch-mlir-plugin)
|
||||
|
||||
add_subdirectory(include/npcomp)
|
||||
add_subdirectory(lib)
|
||||
|
@ -253,7 +253,5 @@ add_subdirectory(python)
|
|||
add_subdirectory(test)
|
||||
add_subdirectory(tools)
|
||||
|
||||
if(NPCOMP_ENABLE_PYTORCH)
|
||||
message(STATUS "Adding PyTorch frontent support...")
|
||||
message(STATUS "Adding PyTorch frontend support...")
|
||||
add_subdirectory(frontends/pytorch)
|
||||
endif()
|
||||
|
|
|
@ -147,7 +147,7 @@ ninja check-npcomp
|
|||
# enable the PyTorch frontend.
|
||||
pip3 install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
|
||||
|
||||
cmake -DNPCOMP_ENABLE_PYTORCH=ON ...
|
||||
cmake ...
|
||||
ninja check-frontends-pytorch # If building with PyTorch
|
||||
```
|
||||
|
||||
|
@ -177,7 +177,7 @@ Build/test npcomp (from within docker image):
|
|||
```shell
|
||||
# From within the docker image.
|
||||
cd /src/mlir-npcomp
|
||||
cmake -GNinja -B/build/npcomp -DCMAKE_BUILD_TYPE=Release -DNPCOMP_ENABLE_PYTORCH=ON .
|
||||
cmake -GNinja -B/build/npcomp -DCMAKE_BUILD_TYPE=Release .
|
||||
cmake --build /build/npcomp --target check-npcomp check-frontends-pytorch
|
||||
```
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Updates auto-generated ODS files for the `torch` dialect.
|
||||
set -e
|
||||
|
||||
src_dir="$(realpath $(dirname $0)/..)"
|
||||
build_dir="$(realpath "${NPCOMP_BUILD_DIR:-$src_dir/build}")"
|
||||
torch_ir_dir="${src_dir}/include/npcomp/Dialect/Torch/IR"
|
||||
|
||||
source $src_dir/.env
|
||||
#ninja -C "${build_dir}"
|
||||
python -m torch_mlir_utils.codegen.torch_ods_gen \
|
||||
--torch_ir_dir="${torch_ir_dir}" \
|
||||
--debug_registry_dump="${torch_ir_dir}/JITOperatorRegistryDump.txt"
|
|
@ -15,8 +15,7 @@ python_packages_dir="$build_dir/python_packages"
|
|||
|
||||
write_env_file() {
|
||||
echo "Updating $build_dir/.env file"
|
||||
echo "PYTHONPATH=\"$(portable_realpath "$python_packages_dir/npcomp_core"):$(portable_realpath "$python_packages_dir/npcomp_torch")\"" > "$build_dir/.env"
|
||||
echo "NUMPY_EXPERIMENTAL_ARRAY_FUNCTION=1" >> "$build_dir/.env"
|
||||
echo "PYTHONPATH=\"$(portable_realpath "$python_packages_dir/npcomp_core"):$(portable_realpath "$python_packages_dir/npcomp_torch"):$(portable_realpath "$python_packages_dir/torch_mlir"):$(portable_realpath "$python_packages_dir/torch_mlir_dialects")\"" > "$build_dir/.env"
|
||||
if ! cp "$build_dir/.env" "$td/.env"; then
|
||||
echo "WARNING: Failed to write $td/.env"
|
||||
fi
|
||||
|
|
|
@ -1,18 +1,3 @@
|
|||
function(npcomp_python_target_compile_options target)
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
# Enable RTTI and exceptions.
|
||||
-frtti -fexceptions
|
||||
# Noisy pybind warnings
|
||||
-Wno-unused-value
|
||||
-Wno-covered-switch-default
|
||||
>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
# Enable RTTI and exceptions.
|
||||
/EHsc /GR>
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(npcomp_python_create_symlinks binary_dir source_dir)
|
||||
# Do nothing if building in-source
|
||||
if (${binary_dir} STREQUAL ${source_dir})
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 830c0b9023cd0cf91955900e0d96283e7a8c3711
|
||||
Subproject commit 8dca953dd39c0cd8c80decbeb38753f58a4de580
|
|
@ -0,0 +1 @@
|
|||
/build
|
|
@ -63,10 +63,14 @@ endif()
|
|||
|
||||
add_subdirectory(include)
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(tools)
|
||||
|
||||
if(MLIR_ENABLE_BINDINGS_PYTHON)
|
||||
#XXX: Enable
|
||||
#add_subdirectory(python)
|
||||
if(NOT TORCH_MLIR_PYTHON_PACKAGES_DIR)
|
||||
set(TORCH_MLIR_PYTHON_PACKAGES_DIR "${CMAKE_CURRENT_BINARY_DIR}/python_packages")
|
||||
endif()
|
||||
add_subdirectory(TorchPlugin)
|
||||
add_subdirectory(python)
|
||||
endif()
|
||||
|
||||
add_subdirectory(test)
|
||||
|
|
|
@ -0,0 +1,235 @@
|
|||
==============================================================================
|
||||
The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
|
||||
As an incubator project with ambition to become part of the LLVM Project,
|
||||
CIRCT is under the same license.
|
||||
==============================================================================
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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
|
||||
|
||||
http://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.
|
||||
|
||||
|
||||
---- LLVM Exceptions to the Apache 2.0 License ----
|
||||
|
||||
As an exception, if, as a result of your compiling your source code, portions
|
||||
of this Software are embedded into an Object form of such source code, you
|
||||
may redistribute such embedded portions in such Object form without complying
|
||||
with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
|
||||
|
||||
In addition, if you combine or link compiled forms of this Software with
|
||||
software that is licensed under the GPLv2 ("Combined Software") and if a
|
||||
court of competent jurisdiction determines that the patent provision (Section
|
||||
3), the indemnity provision (Section 9) or other Section of the License
|
||||
conflicts with the conditions of the GPLv2, you may retroactively and
|
||||
prospectively choose to deem waived or otherwise exclude such Section(s) of
|
||||
the License, but only in their entirety and only with respect to the Combined
|
||||
Software.
|
||||
|
||||
==============================================================================
|
||||
Software from third parties included in the LLVM Project:
|
||||
==============================================================================
|
||||
The LLVM Project contains third party software which is under different license
|
||||
terms. All such code will be identified clearly using at least one of two
|
||||
mechanisms:
|
||||
1) It will be in a separate directory tree with its own `LICENSE.txt` or
|
||||
`LICENSE` file at the top containing the specific license and restrictions
|
||||
which apply to that software, or
|
||||
2) It will contain specific license and restriction terms at the top of every
|
||||
file.
|
|
@ -0,0 +1,41 @@
|
|||
#-------------------------------------------------------------------------------
|
||||
# Sub project setup
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
cmake_minimum_required(VERSION 3.13.4)
|
||||
|
||||
if(POLICY CMP0068)
|
||||
cmake_policy(SET CMP0068 NEW)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0075)
|
||||
cmake_policy(SET CMP0075 NEW)
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif()
|
||||
|
||||
project(torch_mlir_plugin LANGUAGES CXX C)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Setup PyTorch
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
||||
include(TorchMLIRPyTorch)
|
||||
TorchMLIRProbeForPyTorchInstall()
|
||||
find_package(Torch 1.8 REQUIRED)
|
||||
|
||||
TorchMLIRConfigurePyTorch()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Subdirectories
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
add_subdirectory(csrc)
|
||||
add_subdirectory(python)
|
||||
add_subdirectory(test)
|
|
@ -0,0 +1,65 @@
|
|||
In order to facilitate future incorporation in pytorch, the code in this
|
||||
directory (frontends/pytorch) is provided under the below license.
|
||||
|
||||
Copyright (c) 2020 LLVM Foundation.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America
|
||||
and IDIAP Research Institute nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The design of this code is highly inspired by the design of the xla device for
|
||||
pytorch (git@github.com:pytorch/xla.git). The license for pytorch/xla is:
|
||||
|
||||
Copyright (c) 2018 Google Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America
|
||||
and IDIAP Research Institute nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
|
@ -1,8 +1,8 @@
|
|||
# NpcompProbeForPyTorchInstall
|
||||
# TorchMLIRProbeForPyTorchInstall
|
||||
# Attempts to find a Torch installation and set the Torch_ROOT variable
|
||||
# based on introspecting the python environment. This allows a subsequent
|
||||
# call to find_package(Torch) to work.
|
||||
function(NpcompProbeForPyTorchInstall)
|
||||
function(TorchMLIRProbeForPyTorchInstall)
|
||||
if(Torch_ROOT)
|
||||
message(STATUS "Using cached Torch root = ${Torch_ROOT}")
|
||||
else()
|
||||
|
@ -24,7 +24,7 @@ function(NpcompProbeForPyTorchInstall)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
# NpcompConfigurePyTorch
|
||||
# TorchMLIRConfigurePyTorch
|
||||
# Performs configuration of PyTorch flags after CMake has found it to be
|
||||
# present. Most of this comes down to detecting whether building against a
|
||||
# source or official binary and adjusting compiler options in the latter case
|
||||
|
@ -34,7 +34,7 @@ endfunction()
|
|||
# In the future, we may want to switch away from custom building these
|
||||
# extensions and instead rely on the Torch machinery directly (definitely want
|
||||
# to do that for official builds).
|
||||
function(NpcompConfigurePyTorch)
|
||||
function(TorchMLIRConfigurePyTorch)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
# Linux specific libstdcpp ABI checking.
|
||||
message(STATUS "Checking if Torch is an official binary ...")
|
||||
|
@ -58,3 +58,18 @@ function(NpcompConfigurePyTorch)
|
|||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(torch_mlir_python_target_compile_options target)
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
# Enable RTTI and exceptions.
|
||||
-frtti -fexceptions
|
||||
# Noisy pybind warnings
|
||||
-Wno-unused-value
|
||||
-Wno-covered-switch-default
|
||||
>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
# Enable RTTI and exceptions.
|
||||
/EHsc /GR>
|
||||
)
|
||||
endfunction()
|
|
@ -1,8 +1,4 @@
|
|||
include(NpcompPython)
|
||||
|
||||
# TODO: Add this to an npcomp header of some kind so it doesn't need to be
|
||||
# passed loose.
|
||||
add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=npcomp.")
|
||||
# TODO: Add a way to configure MLIR_PYTHON_PACKAGE_PREFIX
|
||||
|
||||
# Sharp edge: Torch extensions need to use the same pybind11 that torch
|
||||
# was compiled with, or else there will be issues in cross module exception
|
||||
|
@ -16,7 +12,7 @@ include_directories(BEFORE
|
|||
)
|
||||
link_directories("${TORCH_INSTALL_PREFIX}/lib")
|
||||
|
||||
add_library(NPCOMPTorchMLIRExt SHARED
|
||||
add_library(TorchMLIRTorchPlugin SHARED
|
||||
builder/acap_dispatch.cpp
|
||||
builder/class_annotator.cpp
|
||||
builder/debug.cpp
|
||||
|
@ -31,16 +27,16 @@ add_library(NPCOMPTorchMLIRExt SHARED
|
|||
init_python_bindings.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(NPCOMPTorchMLIRExt
|
||||
NPCOMPPythonCAPI
|
||||
target_link_libraries(TorchMLIRTorchPlugin
|
||||
TorchMLIRAggregateCAPI
|
||||
${TORCH_LIBRARIES}
|
||||
${Python3_LIBRARIES}
|
||||
torch_python
|
||||
)
|
||||
|
||||
message(STATUS "TORCH_CXXFLAGS=${TORCH_CXXFLAGS}")
|
||||
set_target_properties(NPCOMPTorchMLIRExt PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${MLIR_NPCOMP_PYTHON_PACKAGES_DIR}/npcomp_torch"
|
||||
set_target_properties(TorchMLIRTorchPlugin PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${TORCH_MLIR_PYTHON_PACKAGES_DIR}/torch_mlir"
|
||||
OUTPUT_NAME _torch_mlir
|
||||
PREFIX "${PYTHON_MODULE_PREFIX}"
|
||||
SUFFIX "${PYTHON_MODULE_EXTENSION}"
|
||||
|
@ -48,5 +44,5 @@ set_target_properties(NPCOMPTorchMLIRExt PROPERTIES
|
|||
COMPILE_FLAGS "${TORCH_CXXFLAGS}"
|
||||
)
|
||||
|
||||
npcomp_python_target_compile_options(NPCOMPTorchMLIRExt)
|
||||
mlir_check_all_link_libraries(NPCOMPTorchMLIRExt)
|
||||
torch_mlir_python_target_compile_options(TorchMLIRTorchPlugin)
|
||||
mlir_check_all_link_libraries(TorchMLIRTorchPlugin)
|
|
@ -1,7 +1,7 @@
|
|||
//===- acap_dispatch.cpp --------------------------------------------------===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
@ -35,7 +35,6 @@ using c10::Stack;
|
|||
// own key.
|
||||
// TODO: Ask the PT devs why conv is special and only shows up if dispatching
|
||||
// through the autograd keys.
|
||||
// https://github.com/llvm/mlir-npcomp/issues/86
|
||||
#define ACAP_DISPATCH_KEY PrivateUse2
|
||||
#define ACAP_GRAD_DISPATCH_KEY AutogradPrivateUse2
|
||||
static c10::DispatchKey kAcapDispatchKey = c10::DispatchKey::ACAP_DISPATCH_KEY;
|
|
@ -1,7 +1,7 @@
|
|||
//===- acap_dispatch.h ------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// "ATen Capture" dispatcher: Defines facility for capturing programs by
|
||||
|
@ -11,8 +11,8 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_ACAP_DISPATCH_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_ACAP_DISPATCH_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_BUILDER_ACAP_DISPATCH_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_BUILDER_ACAP_DISPATCH_H
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
@ -128,4 +128,4 @@ private:
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_C10_DISPATCH_ACAP_DISPATCH_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_C10_DISPATCH_ACAP_DISPATCH_H
|
|
@ -1,7 +1,7 @@
|
|||
//===- class_annotator.cpp ------------------------------------------------===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//===- class_annotations.h --------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Utilities for annotating Torch `c10::ClassType`
|
||||
|
@ -18,8 +18,8 @@
|
|||
// of implementation.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_CLASS_ANNOTATOR_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_CLASS_ANNOTATOR_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_CLASS_ANNOTATOR_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_CLASS_ANNOTATOR_H
|
||||
|
||||
#include "../pybind.h"
|
||||
|
||||
|
@ -192,4 +192,4 @@ void initClassAnnotatorBindings(py::module &m);
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_CLASS_ANNOTATOR_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_CLASS_ANNOTATOR_H
|
|
@ -1,7 +1,7 @@
|
|||
//===- debug.cpp ------------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
//===- debug.h --------------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_DEBUG_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_DEBUG_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_BUILDER_DEBUG_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_BUILDER_DEBUG_H
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -24,4 +24,4 @@ void enableDebugTraceToStderr();
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_DEBUG_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_BUILDER_DEBUG_H
|
|
@ -1,7 +1,7 @@
|
|||
//===- func_builder.cpp ---------------------------------------------------===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
//===- func_builder.h -------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_FUNC_BUILDER_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_FUNC_BUILDER_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_BUILDER_FUNC_BUILDER_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_BUILDER_FUNC_BUILDER_H
|
||||
|
||||
#include "mlir_utils.h"
|
||||
#include "torch_to_mlir_utils.h"
|
||||
|
@ -150,4 +150,4 @@ private:
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_FUNC_BUILDER_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_BUILDER_FUNC_BUILDER_H
|
|
@ -1,7 +1,7 @@
|
|||
//===- function_importer.cpp ----------------------------------------------===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
//===- function_importer.h --------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_FUNCTION_IMPORTER_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_FUNCTION_IMPORTER_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_FUNCTION_IMPORTER_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_FUNCTION_IMPORTER_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -47,4 +47,4 @@ MlirOperation importJitFunctionAsFuncOp(
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_FUNCTION_IMPORTER_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_FUNCTION_IMPORTER_H
|
|
@ -1,7 +1,7 @@
|
|||
//===- ivalue_importer.cpp ------------------------------------------------===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
//===- ivalue_importer.h ----------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_IVALUE_IMPORTER_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_IVALUE_IMPORTER_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_IVALUE_IMPORTER_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_IVALUE_IMPORTER_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -29,4 +29,4 @@ void importIValue(c10::IValue ivalue, MlirBlock block, MlirContext context,
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_IVALUE_IMPORTER_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_IVALUE_IMPORTER_H
|
|
@ -1,12 +1,12 @@
|
|||
//===- mlir_utils.h ---------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_MLIR_UTILS_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_MLIR_UTILS_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_MLIR_UTILS_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_MLIR_UTILS_H
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
@ -111,4 +111,4 @@ MlirOperation createMlirOperationAtEnd(MlirBlock block, std::string name,
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_MLIR_UTILS_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_MLIR_UTILS_H
|
|
@ -1,7 +1,7 @@
|
|||
//===- module_builder.cpp -------------------------------------------------===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
|||
#include "mlir-c/BuiltinTypes.h"
|
||||
#include "mlir-c/Diagnostics.h"
|
||||
#include "mlir-c/Registration.h"
|
||||
#include "npcomp-c/Registration.h"
|
||||
#include "torch-mlir-c/Registration.h"
|
||||
|
||||
namespace py = pybind11;
|
|
@ -1,12 +1,12 @@
|
|||
//===- module_builder.h -----------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_BUILDER_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_BUILDER_H
|
||||
|
||||
#include "../pybind.h"
|
||||
|
||||
|
@ -70,4 +70,4 @@ private:
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_C10_DISPATCH_MODULE_BUILDER_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_C10_DISPATCH_MODULE_BUILDER_H
|
|
@ -1,7 +1,7 @@
|
|||
//===- node_importer.cpp --------------------------------------------------===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
//===- node_importer.h ------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_NODE_IMPORTER_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_NODE_IMPORTER_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_NODE_IMPORTER_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_NODE_IMPORTER_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -28,4 +28,4 @@ MlirBlock importBlock(MlirContext context, torch::jit::Block *jitBlock,
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_NODE_IMPORTER_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_NODE_IMPORTER_H
|
|
@ -1,7 +1,7 @@
|
|||
//===- op_builder.cpp -----------------------------------------------------===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
//===- op_builder.h ---------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_OP_BUILDER_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_OP_BUILDER_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_BUILDER_OP_BUILDER_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_BUILDER_OP_BUILDER_H
|
||||
|
||||
#include "mlir_utils.h"
|
||||
#include "torch_to_mlir_utils.h"
|
||||
|
@ -37,4 +37,4 @@ private:
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_BUILDER_OP_BUILDER_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_BUILDER_OP_BUILDER_H
|
|
@ -1,7 +1,7 @@
|
|||
//===- python_bindings.cpp --------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//===- ivalue_importer.cpp ------------------------------------------------===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
@ -323,9 +323,6 @@ MlirAttribute torch_mlir::convertTensorToMlirElementsAttr(at::Tensor tensor,
|
|||
shapedType, numElements, static_cast<const double *>(tensorData));
|
||||
break;
|
||||
case ScalarType::Bool:
|
||||
// TODO: Add a test specifically for bool and ensure consistency between
|
||||
// storage format and load format
|
||||
// (https://github.com/llvm/mlir-npcomp/issues/100).
|
||||
return mlirDenseElementsAttrBoolGet(shapedType, numElements,
|
||||
static_cast<const int *>(tensorData));
|
||||
break;
|
|
@ -1,12 +1,12 @@
|
|||
//===- torch_to_mlir_utils.h ------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_TORCH_TO_MLIR_UTILS_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_TORCH_TO_MLIR_UTILS_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_TORCH_TO_MLIR_UTILS_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_TORCH_TO_MLIR_UTILS_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -98,4 +98,4 @@ MlirOperation createOperationFromSchema(MlirBlock appendToBlock,
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_TORCH_TO_MLIR_UTILS_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_TORCH_TO_MLIR_UTILS_H
|
|
@ -1,16 +1,11 @@
|
|||
//===- init_python_bindings.cpp ---------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// This is the top-level entry point for the MLIR/NPCOMP <-> PyTorch bridge.
|
||||
// It provides several mechanisms for extracting programs from PyTorch via:
|
||||
// a) A pseudo-device which captures the operations to an MLIR module
|
||||
// (implemented via the legacy type_dispatch mechanism for PyTorch 1.3).
|
||||
// b) Direct IR translation from PyTorch Graphs (not implemented).
|
||||
// c) Using the PyTorch JIT facility (not implemented).
|
||||
// This is the top-level entry point for the MLIR <-> PyTorch bridge.
|
||||
|
||||
#include "init_python_bindings.h"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//===- init_python_bindings.h -----------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//===- module_builder.h -----------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This file is licensed under a pytorch-style license
|
||||
// See frontends/pytorch/LICENSE for license information.
|
||||
// See LICENSE for license information.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Includes Torch-specific pybind and associated helpers.
|
||||
|
@ -9,8 +9,8 @@
|
|||
// directly).
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_FRONTENDS_PYTORCH_CSRC_PYBIND_H
|
||||
#define NPCOMP_FRONTENDS_PYTORCH_CSRC_PYBIND_H
|
||||
#ifndef TORCHMLIRPLUGIN_CSRC_PYBIND_H
|
||||
#define TORCHMLIRPLUGIN_CSRC_PYBIND_H
|
||||
|
||||
#include <torch/csrc/utils/pybind.h>
|
||||
|
||||
|
@ -25,4 +25,4 @@ public:
|
|||
|
||||
} // namespace torch_mlir
|
||||
|
||||
#endif // NPCOMP_FRONTENDS_PYTORCH_CSRC_PYBIND_H
|
||||
#endif // TORCHMLIRPLUGIN_CSRC_PYBIND_H
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
## Declare the sources of the Python module.
|
||||
|
||||
declare_mlir_python_sources(TorchMLIRPluginPythonSources)
|
||||
|
||||
declare_mlir_python_sources(TorchMLIRPluginPythonSources.Core
|
||||
ADD_TO_PARENT TorchMLIRPluginPythonSources
|
||||
SOURCES_GLOB
|
||||
torch_mlir/*.py
|
||||
torch_mlir_utils/codegen/*.py
|
||||
)
|
||||
|
||||
set(_source_components
|
||||
TorchMLIRPluginPythonSources
|
||||
)
|
||||
|
||||
add_mlir_python_modules(TorchMLIRPluginPythonModules
|
||||
ROOT_PREFIX "${TORCH_MLIR_PYTHON_PACKAGES_DIR}/torch_mlir"
|
||||
INSTALL_PREFIX "python_packages/torch_mlir"
|
||||
DECLARED_SOURCES ${_source_components}
|
||||
COMMON_CAPI_LINK_LIBS
|
||||
TorchMLIRAggregateCAPI
|
||||
)
|
||||
add_dependencies(TorchMLIRPluginPythonModules TorchMLIRTorchPlugin)
|
|
@ -7,7 +7,6 @@
|
|||
# prior to loading shared objects.
|
||||
|
||||
import torch
|
||||
import npcomp._mlir_libs._npcomp
|
||||
|
||||
# Our native extension is not self-contained. It references libraries which
|
||||
# must come in via the above first.
|
|
@ -34,12 +34,12 @@ def _recursively_extract_annotations(
|
|||
if not isinstance(scripted_method, torch.ScriptMethod):
|
||||
continue
|
||||
method = getattr(module, method_name)
|
||||
if hasattr(method, '_npcomp_export'):
|
||||
if hasattr(method, '_torch_mlir_export'):
|
||||
class_annotator.exportPath(scripted._c._type(), [method_name])
|
||||
if hasattr(method, '_npcomp_arg_annotations'):
|
||||
if hasattr(method, '_torch_mlir_arg_annotations'):
|
||||
class_annotator.annotateArgs(
|
||||
scripted._c._type(), [method_name],
|
||||
method._npcomp_arg_annotations)
|
||||
method._torch_mlir_arg_annotations)
|
||||
# Recurse.
|
||||
for name, child in module.named_children():
|
||||
scripted_child = getattr(scripted, name)
|
|
@ -22,9 +22,8 @@ extension_sources = [str(p) for p in this_dir.joinpath("csrc").rglob("*.cpp")]
|
|||
include_dirs = npcomp_build.get_include_dirs()
|
||||
lib_dirs = npcomp_build.get_lib_dirs()
|
||||
npcomp_libs = [npcomp_build.get_capi_link_library_name()]
|
||||
# TODO: Export this in some way from an npcomp config file include vs needing
|
||||
# it loose here.
|
||||
compile_args = ["-DMLIR_PYTHON_PACKAGE_PREFIX=npcomp."]
|
||||
# TODO: Add a way to customize MLIR_PYTHON_PACKAGE_PREFIX
|
||||
compile_args = []
|
||||
|
||||
setup(
|
||||
name="npcomp-torch",
|
|
@ -0,0 +1,21 @@
|
|||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
|
||||
MAIN_CONFIG
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
|
||||
)
|
||||
|
||||
set(TEST_DEPENDS
|
||||
FileCheck count not
|
||||
torch-mlir-opt
|
||||
TorchMLIRTorchPlugin
|
||||
)
|
||||
|
||||
add_lit_testsuite(check-torch-mlir-plugin
|
||||
"Running the torch-mlir-plugin regression tests"
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS ${TEST_DEPENDS}
|
||||
)
|
||||
set_target_properties(check-torch-mlir-plugin PROPERTIES FOLDER "Tests")
|
||||
|
||||
add_lit_testsuites(TORCH_MLIR_PLUGIN ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${TEST_DEPENDS})
|
|
@ -1,11 +1,11 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
torch_mlir.debug_trace_to_stderr()
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
|
@ -1,8 +1,8 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
# XFAIL: *
|
||||
|
||||
import torch
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
t0 = torch.randn((1,2,3,4))
|
||||
t1 = torch.randn((1,2,3,4))
|
|
@ -1,11 +1,11 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
import torch
|
||||
import torch.nn as nn
|
|
@ -1,11 +1,11 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
# RUN: %PYTHON %s | FileCheck %s
|
||||
|
||||
import _torch_mlir
|
|
@ -1,8 +1,8 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt -aten-recognize-kernels -numpy-public-functions-to-tensor -canonicalize | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt -aten-recognize-kernels -numpy-public-functions-to-tensor -canonicalize | FileCheck %s
|
||||
# TODO: Re-enable after adding support for 4-operand aten::add in `aten-recognize-kernels`.
|
||||
# XFAIL: *
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
# Some checks that we can import the various extensions and libraries and
|
||||
# not have symbol collisions or other goings on.
|
||||
|
@ -10,7 +10,7 @@ import sys
|
|||
|
||||
print(f"PYTHONPATH={sys.path}")
|
||||
|
||||
import npcomp.ir
|
||||
import mlir.ir
|
||||
import torch_mlir
|
||||
|
||||
print("Extensions all loaded")
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
from typing import Dict, Optional
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See LICENSE for license information.
|
||||
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
import lit.formats
|
||||
import lit.util
|
||||
|
||||
from lit.llvm import llvm_config
|
||||
from lit.llvm.subst import ToolSubst
|
||||
from lit.llvm.subst import FindTool
|
||||
|
||||
# Configuration file for the 'lit' test runner.
|
||||
|
||||
# name: The name of this test suite.
|
||||
config.name = 'TORCH_MLIR_PLUGIN'
|
||||
|
||||
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
|
||||
if 'TEST_SRC_PATH' in os.environ:
|
||||
config.environment['TEST_SRC_PATH'] = os.environ['TEST_SRC_PATH']
|
||||
|
||||
# path to our python operation library
|
||||
config.environment['TEST_BUILD_PATH'] = os.path.join(config.torch_mlir_plugin_obj_root)
|
||||
|
||||
# suffixes: A list of file extensions to treat as test files.
|
||||
config.suffixes = ['.py']
|
||||
|
||||
# test_source_root: The root path where tests are located.
|
||||
config.test_source_root = os.path.dirname(__file__)
|
||||
|
||||
# test_exec_root: The root path where tests should be run.
|
||||
config.test_exec_root = os.path.join(config.torch_mlir_plugin_obj_root, 'test')
|
||||
|
||||
config.substitutions.append(('%PATH%', config.environment['PATH']))
|
||||
config.substitutions.append(('%shlibext', config.llvm_shlib_ext))
|
||||
config.substitutions.append(('%PYTHON', config.python_executable))
|
||||
|
||||
llvm_config.with_system_environment(
|
||||
['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP'])
|
||||
|
||||
llvm_config.use_default_substitutions()
|
||||
|
||||
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
|
||||
# subdirectories contain auxiliary inputs for various tests in their parent
|
||||
# directories.
|
||||
config.excludes = ['lit.cfg.py', 'Inputs', 'Examples', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
|
||||
|
||||
# test_source_root: The root path where tests are located.
|
||||
config.test_source_root = os.path.dirname(__file__)
|
||||
|
||||
# test_exec_root: The root path where tests should be run.
|
||||
config.test_exec_root = os.path.join(config.torch_mlir_plugin_obj_root, 'test')
|
||||
config.torch_mlir_tools_dir = os.path.join(config.torch_mlir_plugin_obj_root, 'bin')
|
||||
|
||||
# Tweak the PATH to include the tools dir.
|
||||
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
|
||||
llvm_config.with_environment('PYTHONPATH', [
|
||||
os.path.join(config.torch_mlir_python_packages_dir, 'torch_mlir'),
|
||||
os.path.join(config.torch_mlir_python_packages_dir, 'torch_mlir_dialects'),
|
||||
],
|
||||
append_path=True)
|
||||
|
||||
|
||||
tool_dirs = [config.torch_mlir_tools_dir, config.llvm_tools_dir]
|
||||
tools = [
|
||||
'torch-mlir-opt',
|
||||
]
|
||||
|
||||
llvm_config.add_tool_substitutions(tools, tool_dirs)
|
|
@ -0,0 +1,56 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See LICENSE for license information.
|
||||
|
||||
@LIT_SITE_CFG_IN_HEADER@
|
||||
|
||||
import sys
|
||||
|
||||
config.host_triple = "@LLVM_HOST_TRIPLE@"
|
||||
config.target_triple = "@TARGET_TRIPLE@"
|
||||
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
|
||||
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
|
||||
# TODO: Fix tools dir to find FileCheck.
|
||||
#config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
|
||||
config.llvm_tools_dir = "@LLVM_BINARY_DIR@/bin"
|
||||
config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
|
||||
config.llvm_shlib_dir = "@SHLIBDIR@"
|
||||
config.llvm_shlib_ext = "@SHLIBEXT@"
|
||||
config.llvm_exe_ext = "@EXEEXT@"
|
||||
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
|
||||
config.python_executable = "@Python3_EXECUTABLE@"
|
||||
config.gold_executable = "@GOLD_EXECUTABLE@"
|
||||
config.ld64_executable = "@LD64_EXECUTABLE@"
|
||||
config.enable_shared = @ENABLE_SHARED@
|
||||
config.enable_assertions = @ENABLE_ASSERTIONS@
|
||||
config.targets_to_build = "@TARGETS_TO_BUILD@"
|
||||
config.native_target = "@LLVM_NATIVE_ARCH@"
|
||||
config.llvm_bindings = "@LLVM_BINDINGS@".split(' ')
|
||||
config.host_os = "@HOST_OS@"
|
||||
config.host_cc = "@HOST_CC@"
|
||||
config.host_cxx = "@HOST_CXX@"
|
||||
# Note: ldflags can contain double-quoted paths, so must use single quotes here.
|
||||
config.host_ldflags = '@HOST_LDFLAGS@'
|
||||
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
|
||||
config.llvm_host_triple = '@LLVM_HOST_TRIPLE@'
|
||||
config.host_arch = "@HOST_ARCH@"
|
||||
config.torch_mlir_plugin_src_root = "@CMAKE_SOURCE_DIR@"
|
||||
config.torch_mlir_plugin_obj_root = "@CMAKE_BINARY_DIR@"
|
||||
config.torch_mlir_python_packages_dir = "@TORCH_MLIR_PYTHON_PACKAGES_DIR@"
|
||||
|
||||
# Support substitution of the tools_dir with user parameters. This is
|
||||
# used when we can't determine the tool dir at configuration time.
|
||||
try:
|
||||
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
|
||||
config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
|
||||
except KeyError:
|
||||
e = sys.exc_info()[1]
|
||||
key, = e.args
|
||||
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
|
||||
|
||||
|
||||
import lit.llvm
|
||||
lit.llvm.initialize(lit_config, config)
|
||||
|
||||
# Let the main config do the real work.
|
||||
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
import collections
|
||||
from typing import Tuple, Optional, List, NamedTuple, Dict
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import enum
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
import typing
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
import typing
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import typing
|
||||
|
||||
|
@ -9,7 +9,7 @@ import torch_mlir
|
|||
|
||||
import typing
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
import collections
|
||||
from typing import Tuple, Optional, NamedTuple
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
NT = NamedTuple('NT', [('f1', Optional[torch.Tensor]),
|
|
@ -1,11 +1,11 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
# -*- Python -*-
|
||||
# This file is licensed under a pytorch-style license
|
||||
# See frontends/pytorch/LICENSE for license information.
|
||||
# See LICENSE for license information.
|
||||
|
||||
import torch
|
||||
import torch_mlir
|
||||
|
||||
# RUN: %PYTHON %s | npcomp-opt | FileCheck %s
|
||||
# RUN: %PYTHON %s | torch-mlir-opt | FileCheck %s
|
||||
|
||||
mb = torch_mlir.ModuleBuilder()
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Simple script that does a CMake configure of this project as an external
|
||||
# LLVM project so it can be tested in isolation to larger assemblies.
|
||||
# This is meant for CI's and project maintainers.
|
||||
|
||||
set -eu -o errtrace
|
||||
|
||||
project_dir="$(cd $(dirname $0)/.. && pwd)"
|
||||
llvm_project_dir="$project_dir/../llvm-project"
|
||||
build_dir="$project_dir/build"
|
||||
|
||||
cmake -GNinja -B"$build_dir" "$llvm_project_dir/llvm" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DLLVM_ENABLE_PROJECTS=mlir \
|
||||
-DLLVM_EXTERNAL_PROJECTS=torch-mlir \
|
||||
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$project_dir" \
|
||||
-DMLIR_ENABLE_BINDINGS_PYTHON=ON
|
||||
|
||||
cd "$build_dir"
|
||||
ninja tools/torch-mlir/all check-torch-mlir check-torch-mlir-plugin
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
# Updates auto-generated ODS files for the `torch` dialect.
|
||||
set -e
|
||||
|
||||
src_dir="$(realpath $(dirname $0)/..)"
|
||||
build_dir="$(realpath "${TORCH_MLIR_BUILD_DIR:-$src_dir/build}")"
|
||||
torch_ir_dir="${src_dir}/include/torch-mlir/Dialect/Torch/IR"
|
||||
python_packages_dir="${build_dir}/tools/torch-mlir/python_packages"
|
||||
|
||||
#ninja -C "${build_dir}"
|
||||
PYTHONPATH="${python_packages_dir}/torch_mlir" python -m torch_mlir_utils.codegen.torch_ods_gen \
|
||||
--torch_ir_dir="${torch_ir_dir}" \
|
||||
--debug_registry_dump="${torch_ir_dir}/JITOperatorRegistryDump.txt"
|
|
@ -0,0 +1,25 @@
|
|||
/*===-- torch-mlir-c/Dialects.h - Dialect functions --------------*- C -*-===*\
|
||||
|* *|
|
||||
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|
||||
|* Exceptions. *|
|
||||
|* See https://llvm.org/LICENSE.txt for license information. *|
|
||||
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|
||||
|* *|
|
||||
\*===----------------------------------------------------------------------===*/
|
||||
|
||||
#ifndef TORCHMLIR_C_DIALECTS_H
|
||||
#define TORCHMLIR_C_DIALECTS_H
|
||||
|
||||
#include "mlir-c/Registration.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Torch, torch);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TORCHMLIR_C_DIALECTS_H
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue