Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
d47cf332
MegEngine
项目概览
MegEngine 天元
/
MegEngine
大约 1 年 前同步成功
通知
399
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d47cf332
编写于
9月 25, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
build(third_party): update llvm-project and adapt to mlir interface changes
GitOrigin-RevId: dd45984ccaeef39094f9a209abe490d10e54a77e
上级
95f6b531
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
42 addition
and
19 deletion
+42
-19
cmake/llvm-project.cmake
cmake/llvm-project.cmake
+9
-5
src/jit/impl/mlir/compiler.cpp
src/jit/impl/mlir/compiler.cpp
+3
-2
src/jit/impl/mlir/ir/dialect.cpp
src/jit/impl/mlir/ir/dialect.cpp
+2
-1
src/jit/impl/mlir/ir/lower_to_affine_pass.cpp
src/jit/impl/mlir/ir/lower_to_affine_pass.cpp
+5
-0
src/jit/impl/mlir/ir/lower_to_gpu_pass.cpp
src/jit/impl/mlir/ir/lower_to_gpu_pass.cpp
+5
-0
src/jit/impl/mlir/ir/lower_to_llvm_pass.cpp
src/jit/impl/mlir/ir/lower_to_llvm_pass.cpp
+8
-0
src/jit/impl/mlir/ir/types.h
src/jit/impl/mlir/ir/types.h
+1
-1
src/jit/impl/mlir/ir/utils.cpp
src/jit/impl/mlir/ir/utils.cpp
+6
-7
src/jit/include/megbrain/jit/mlir/ir/dialect.h
src/jit/include/megbrain/jit/mlir/ir/dialect.h
+3
-3
未找到文件。
cmake/llvm-project.cmake
浏览文件 @
d47cf332
...
...
@@ -49,6 +49,14 @@ function(external_tablegen_library)
install
(
TARGETS
${
_NAME
}
EXPORT
${
MGE_EXPORT_TARGETS
}
)
endfunction
()
set
(
LLVM_LIBS LLVMCore LLVMSupport LLVMX86CodeGen LLVMOrcJIT LLVMNVPTXCodeGen LLVMNVPTXDesc LLVMNVPTXInfo
)
set
(
MLIR_CORE_LIBS MLIRAnalysis MLIRExecutionEngine MLIRIR MLIRParser MLIRPass MLIRSideEffectInterfaces MLIRTransforms
)
set
(
MLIR_DIALECT_LIBS MLIRAsync MLIRAVX512 MLIRGPU MLIRLLVMAVX512 MLIRNVVMIR MLIROpenACC MLIRPDL MLIRPDLInterp MLIRQuant MLIRROCDLIR MLIRSDBM MLIRShape MLIRSPIRV MLIRStandardOpsTransforms
)
set
(
MLIR_CONVERSION_LIBS MLIRAffineToStandard MLIRAVX512ToLLVM MLIRGPUToGPURuntimeTransforms MLIRGPUToNVVMTransforms MLIRSCFToStandard
)
set
(
MLIR_TRANSLATION_LIBS MLIRTargetLLVMIR MLIRTargetNVVMIR
)
set
(
MLIR_LIBS
${
MLIR_CORE_LIBS
}
${
MLIR_DIALECT_LIBS
}
${
MLIR_CONVERSION_LIBS
}
${
MLIR_TRANSLATION_LIBS
}
)
set
(
MLIR_LLVM_LIBS
${
LLVM_LIBS
}
${
MLIR_LIBS
}
)
if
(
MGE_USE_SYSTEM_LIB
)
find_package
(
ZLIB
)
find_package
(
MLIR REQUIRED CONFIG
)
...
...
@@ -77,9 +85,7 @@ if (MGE_USE_SYSTEM_LIB)
endif
()
endfunction
(
find_mlir_llvm_lib
)
set
(
MLIR_COMPONENTS MLIRAnalysis;MLIRExecutionEngine;MLIRIR;MLIRParser;MLIRPass;MLIRSideEffectInterfaces;MLIRTargetLLVMIR;MLIRTransforms;MLIRAffineToStandard;MLIRSCFToStandard;MLIRAVX512ToLLVM;MLIRAVX512;MLIRLLVMAVX512;MLIRSDBM;MLIRROCDLIR;MLIRGPU;MLIRQuant;MLIRSPIRV;MLIRNVVMIR;MLIRShape;MLIRGPUToNVVMTransforms;MLIRTargetNVVMIR;MLIRGPUToGPURuntimeTransforms;MLIRStandardOpsTransforms
)
foreach
(
c
${
MLIR_COMPONENTS
}
)
foreach
(
c
${
MLIR_LIBS
}
)
find_mlir_llvm_lib
(
${
c
}
)
endforeach
()
return
()
...
...
@@ -119,5 +125,3 @@ set(MLIR_LLVM_INCLUDE_DIR
${
PROJECT_BINARY_DIR
}
/third_party/llvm-project/llvm/tools/mlir/include
)
set
(
MLIR_TABLEGEN_EXE mlir-tblgen
)
set
(
MLIR_LLVM_LIBS LLVMCore;LLVMSupport;LLVMX86CodeGen;LLVMOrcJIT;LLVMNVPTXCodeGen;LLVMNVPTXDesc;LLVMNVPTXInfo;MLIRAnalysis;MLIRExecutionEngine;MLIRIR;MLIRParser;MLIRPass;MLIRSideEffectInterfaces;MLIRTargetLLVMIR;MLIRTransforms;MLIRAffineToStandard;MLIRSCFToStandard;MLIRAVX512ToLLVM;MLIRAVX512;MLIRLLVMAVX512;MLIRSDBM;MLIRROCDLIR;MLIRGPU;MLIRQuant;MLIRSPIRV;MLIRNVVMIR;MLIRGPUToNVVMTransforms;MLIRShape;MLIRTargetNVVMIR;MLIRGPUToGPURuntimeTransforms;MLIRStandardOpsTransforms
)
src/jit/impl/mlir/compiler.cpp
浏览文件 @
d47cf332
...
...
@@ -67,8 +67,8 @@ mlir::OwnedBlob compile_ptx_to_cubin(const std::string ptx, mlir::Location,
}
std
::
unique_ptr
<
llvm
::
Module
>
translate_module_to_nvvm_ir_and_link_device
(
Operation
*
m
)
{
std
::
unique_ptr
<
llvm
::
Module
>
module
=
mlir
::
translateModuleToNVVMIR
(
m
);
Operation
*
m
,
llvm
::
LLVMContext
&
llvmContext
,
llvm
::
StringRef
name
)
{
std
::
unique_ptr
<
llvm
::
Module
>
module
=
mlir
::
translateModuleToNVVMIR
(
m
,
llvmContext
);
auto
get_device_path
=
[]()
->
std
::
string
{
auto
cuda_path
=
getenv
(
"CUDA_BIN_PATH"
);
std
::
string
device_dir
;
...
...
@@ -223,6 +223,7 @@ void MLIRCompiler::run_lowering_pass(mlir::OwningModuleRef& module,
std
::
unique_ptr
<
Executable
>
MLIRCompiler
::
do_compile
(
const
InternalGraph
&
graph
,
const
JITExecutor
::
Args
&
args
)
{
mlir
::
MLIRContext
ctx
;
ctx
.
getOrLoadDialect
<
MgbDialect
>
();
ctx
.
printStackTraceOnDiagnostic
(
true
);
ctx
.
printOpOnDiagnostic
(
true
);
...
...
src/jit/impl/mlir/ir/dialect.cpp
浏览文件 @
d47cf332
...
...
@@ -24,7 +24,8 @@
using
namespace
mgb
;
using
namespace
jit
;
MgbDialect
::
MgbDialect
(
mlir
::
MLIRContext
*
ctx
)
:
mlir
::
Dialect
(
"mgb"
,
ctx
)
{
MgbDialect
::
MgbDialect
(
mlir
::
MLIRContext
*
ctx
)
:
mlir
::
Dialect
(
"mgb"
,
ctx
,
mlir
::
TypeID
::
get
<
MgbDialect
>
())
{
addOperations
<
#define GET_OP_LIST
#include "megbrain/jit/mlir/ir/ops.cpp.inc"
...
...
src/jit/impl/mlir/ir/lower_to_affine_pass.cpp
浏览文件 @
d47cf332
...
...
@@ -209,6 +209,11 @@ struct ConstantScalarOpLowering
class
MgbToAffineLoweringPass
:
public
PassWrapper
<
MgbToAffineLoweringPass
,
FunctionPass
>
{
public:
void
getDependentDialects
(
mlir
::
DialectRegistry
&
registry
)
const
override
{
registry
.
insert
<
mlir
::
AffineDialect
>
();
registry
.
insert
<
mlir
::
StandardOpsDialect
>
();
}
void
runOnFunction
()
override
final
{
ConversionTarget
target
(
getContext
());
target
.
addLegalDialect
<
AffineDialect
,
StandardOpsDialect
>
();
...
...
src/jit/impl/mlir/ir/lower_to_gpu_pass.cpp
浏览文件 @
d47cf332
...
...
@@ -259,6 +259,11 @@ private:
class
MgbToGpuLoweringPass
:
public
PassWrapper
<
MgbToGpuLoweringPass
,
FunctionPass
>
{
public:
void
getDependentDialects
(
mlir
::
DialectRegistry
&
registry
)
const
override
{
registry
.
insert
<
mlir
::
gpu
::
GPUDialect
>
();
registry
.
insert
<
mlir
::
StandardOpsDialect
>
();
}
void
runOnFunction
()
override
final
{
auto
func_op
=
getFunction
();
Location
loc
=
func_op
.
getLoc
();
...
...
src/jit/impl/mlir/ir/lower_to_llvm_pass.cpp
浏览文件 @
d47cf332
...
...
@@ -21,6 +21,8 @@
#include <mlir/Conversion/SCFToStandard/SCFToStandard.h>
#include <mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h>
#include <mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h>
#include <mlir/Dialect/LLVMIR/LLVMDialect.h>
#include <mlir/Dialect/SCF/SCF.h>
#include <mlir/Dialect/StandardOps/Transforms/Passes.h>
using
namespace
mgb
;
...
...
@@ -30,6 +32,12 @@ namespace {
class
AffineToLLVMLoweringPass
:
public
PassWrapper
<
AffineToLLVMLoweringPass
,
OperationPass
<
ModuleOp
>>
{
public:
void
getDependentDialects
(
mlir
::
DialectRegistry
&
registry
)
const
override
{
registry
.
insert
<
mlir
::
LLVM
::
LLVMDialect
>
();
registry
.
insert
<
mlir
::
scf
::
SCFDialect
>
();
}
void
runOnOperation
()
final
{
LLVMConversionTarget
target
(
getContext
());
target
.
addLegalOp
<
ModuleOp
,
ModuleTerminatorOp
>
();
...
...
src/jit/impl/mlir/ir/types.h
浏览文件 @
d47cf332
...
...
@@ -21,7 +21,7 @@ namespace jit {
inline
bool
is_elemwise_float
(
const
mlir
::
Type
&
dt
)
{
if
(
auto
cast
=
dt
.
dyn_cast_or_null
<
mlir
::
MemRefType
>
())
{
if
(
cast
.
getElementType
().
getKind
()
==
mlir
::
StandardTypes
::
F32
)
{
if
(
cast
.
getElementType
().
isF32
()
)
{
return
true
;
}
}
...
...
src/jit/impl/mlir/ir/utils.cpp
浏览文件 @
d47cf332
...
...
@@ -82,13 +82,12 @@ megdnn::DType jit::mlir_type_to_dtype(mlir::Type type) {
if
(
auto
cast
=
type
.
dyn_cast_or_null
<
mlir
::
MemRefType
>
())
{
element_type
=
cast
.
getElementType
();
}
switch
(
element_type
.
getKind
())
{
case
mlir
::
StandardTypes
::
F32
:
return
megdnn
::
dtype
::
Float32
{};
default:
mgb_throw
(
InternalError
,
"Unsupport mlir type for MemRefType, got: %s
\n
"
,
mlir_type_to_string
(
type
).
c_str
());
if
(
element_type
.
isF32
())
{
return
megdnn
::
dtype
::
Float32
{};
}
else
{
mgb_throw
(
InternalError
,
"Unsupport mlir type for MemRefType, got: %s
\n
"
,
mlir_type_to_string
(
type
).
c_str
());
}
return
{};
}
...
...
src/jit/include/megbrain/jit/mlir/ir/dialect.h
浏览文件 @
d47cf332
...
...
@@ -34,13 +34,13 @@ public:
static
llvm
::
StringRef
getDialectNamespace
()
{
return
"mgb::jit"
;
}
};
}
// namespace jit
}
// namespace mgb
#define GET_OP_CLASSES
using
namespace
mlir
;
#include "megbrain/jit/mlir/ir/ops.h.inc"
}
// namespace jit
}
// namespace mgb
#endif // MGB_JIT && MGB_JIT_MLIR
// vim: syntax=cpp.doxygen
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录