diff --git a/scripts/whl/BUILD_PYTHON_WHL_README.md b/scripts/whl/BUILD_PYTHON_WHL_README.md index 4270a751e3e9e0b86708850ce9262f6955fb8a19..963711c4b272af79068dca34476ad0859d8b7edb 100755 --- a/scripts/whl/BUILD_PYTHON_WHL_README.md +++ b/scripts/whl/BUILD_PYTHON_WHL_README.md @@ -56,9 +56,9 @@ ``` # How to build -Note: Guarantee the git repo is mounted in docker container, do not use `git submodule update --init` in to init megbrain repo +Note: Guarantee the git repo is mounted in docker container, do not use `git submodule update --init` in to init Project repo ## Build for linux -* MegBrain delivers `wheel` package with `manylinux2014` tag defined in [PEP-571](https://www.python.org/dev/peps/pep-0571/). +* This Project delivers `wheel` package with `manylinux2014` tag defined in [PEP-571](https://www.python.org/dev/peps/pep-0571/). commands: ```bash export CUDA_ROOT_DIR=/path/to/cuda diff --git a/tools/mlir/mgb-file-check/CMakeLists.txt b/tools/mlir/mgb-file-check/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f13106701e7490b185be082ffdc270d3f7a9e58f --- /dev/null +++ b/tools/mlir/mgb-file-check/CMakeLists.txt @@ -0,0 +1,8 @@ +add_custom_command( + OUTPUT link_sh + COMMAND ${CMAKE_COMMAND} -E create_symlink + ${PROJECT_SOURCE_DIR}/tools/mlir/mgb-file-check/mgb-file-check.sh + ${PROJECT_BINARY_DIR}/tools/mlir/mgb-file-check/mgb-file-check +) + +add_custom_target(mgb-file-check DEPENDS link_sh) \ No newline at end of file diff --git a/tools/mlir/mgb-file-check/mgb-file-check.sh b/tools/mlir/mgb-file-check/mgb-file-check.sh new file mode 100755 index 0000000000000000000000000000000000000000..8d68908dd8a990ac5a5cf1cf8a47543904c2ef01 --- /dev/null +++ b/tools/mlir/mgb-file-check/mgb-file-check.sh @@ -0,0 +1,3 @@ +#!/bin/bash -e + +FileCheck --enable-var-scope --dump-input=fail "$@" diff --git a/tools/mlir/mgb-opt/CMakeLists.txt b/tools/mlir/mgb-opt/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..26f1a873ee317e6bb677aed670ece3b27822b2f7 --- /dev/null +++ b/tools/mlir/mgb-opt/CMakeLists.txt @@ -0,0 +1,23 @@ +get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) +get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS) +set(LIBS + ${dialect_libs} + ${conversion_libs} + LLVMSupport + MLIROptLib + MLIRIR + MLIRPass + MLIRSupport + ) +add_executable(mgb-opt mgb-opt.cpp) + +target_include_directories( + mgb-opt + PRIVATE ${MLIR_LLVM_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/src/jit/include + ${PROJECT_BINARY_DIR}/src/jit/include) + +add_dependencies(mgb-opt mgb_dialect) + +target_link_libraries(mgb-opt PRIVATE ${LIBS} megbrain megdnn ${MGE_CUDA_LIBS}) + +llvm_update_compile_flags(mgb-opt) diff --git a/tools/mlir/mgb-opt/mgb-opt.cpp b/tools/mlir/mgb-opt/mgb-opt.cpp new file mode 100644 index 0000000000000000000000000000000000000000..14b8dde7d1f5a0c97380e6a588679c1c04be0133 --- /dev/null +++ b/tools/mlir/mgb-opt/mgb-opt.cpp @@ -0,0 +1,85 @@ +/** + * \file tools/mlir/mgb-opt/mgb-opt.cpp + * MegEngine is Licensed under the Apache License, Version 2.0 (the "License") + * + * Copyright (c) 2014-2021 Megvii Inc. All rights reserved. + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + */ + +#include "megbrain/jit/mlir/ir/dialect.h" +#include "megbrain/jit/mlir/ir/passes.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace llvm; +using namespace mlir; + +//! TODO: Implement a custom MlirOptMain that supports the following flags. +static cl::opt print_mlir{ + "print-mlir", + cl::desc("Prints MLIR IR after translation"), + cl::init(false), +}; + +static cl::list input_values{ + "input-value", + cl::desc("Input shapes and optional values"), + cl::ZeroOrMore, +}; + +static cl::opt input_values_file{ + "input-value-file", + cl::desc("Provides a file for input shapes and optional values (see " + "ParseToVariantListFromFile in vm_util.h for details)"), + cl::init(""), +}; + +static cl::opt run{ + "run", + cl::desc("Runs the module (vs. just compiling and verifing)"), + cl::init(true), +}; + +static cl::list run_args{ + "run-arg", + cl::desc("Argument passed to the execution flag parser"), + cl::ZeroOrMore, +}; + +namespace mgb { +namespace jit { +void register_test_mgb_to_affine_lowering_pass(); +void register_test_affine_to_llvm_lowering_pass(); +} // namespace jit +} // namespace mgb + +int main(int argc, char** argv) { + mlir::registerAllPasses(); + + mlir::DialectRegistry registry; + mlir::registerAllDialects(registry); + registry.insert(); + + mgb::jit::register_test_mgb_to_affine_lowering_pass(); + mgb::jit::register_test_affine_to_llvm_lowering_pass(); + + return failed(MlirOptMain(argc, argv, "MLIR modular optimizer driver", registry)); +}