Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
d793c87c
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d793c87c
编写于
11月 11, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(mlir/dialect): redefine mgb dialect
GitOrigin-RevId: ac0653474655a2b5b89002e888592415fd472190
上级
005ead5a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
94 addition
and
0 deletion
+94
-0
CMakeLists.txt
CMakeLists.txt
+21
-0
src/jit/impl/mlir/ir/CMakeLists.txt
src/jit/impl/mlir/ir/CMakeLists.txt
+8
-0
src/jit/include/megbrain/jit/mlir/ir/mgb_dialect.td
src/jit/include/megbrain/jit/mlir/ir/mgb_dialect.td
+65
-0
未找到文件。
CMakeLists.txt
浏览文件 @
d793c87c
...
...
@@ -750,6 +750,27 @@ target_include_directories(mgb_opr_param_defs
add_dependencies
(
mgb_opr_param_defs _mgb_opr_param_defs
)
install
(
TARGETS mgb_opr_param_defs EXPORT
${
MGE_EXPORT_TARGETS
}
)
if
(
MGE_WITH_JIT_MLIR
)
# generate param_defs.td
set
(
MGE_GENFILE_DIR
${
PROJECT_BINARY_DIR
}
/src/genfiles
)
set
(
OPR_PARAM_DEFS_SRCS
${
MGE_GENFILE_DIR
}
/opr_param_defs.py
)
set
(
OPR_PARAM_DEFS_SCRIPT
${
PROJECT_SOURCE_DIR
}
/dnn/scripts/gen_tablegen.py
)
set
(
OPR_PARAM_DEFS_OUT
${
MGE_GENFILE_DIR
}
/param_defs.td
)
file
(
COPY
${
PROJECT_SOURCE_DIR
}
/dnn/scripts/opr_param_defs.py DESTINATION
${
MGE_GENFILE_DIR
}
)
file
(
READ
${
PROJECT_SOURCE_DIR
}
/tools/param_defs/mgb_opr_param_defs.py CONTENTS
)
file
(
APPEND
${
OPR_PARAM_DEFS_SRCS
}
${
CONTENTS
}
)
add_custom_target
(
param_defs_tblgen
COMMAND
${
PYTHON_EXECUTABLE
}
${
OPR_PARAM_DEFS_SCRIPT
}
${
OPR_PARAM_DEFS_SRCS
}
${
OPR_PARAM_DEFS_OUT
}
DEPENDS
${
OPR_PARAM_DEFS_SRCS
}
${
OPR_PARAM_DEFS_SCRIPT
}
VERBATIM
)
# mlir tblgen sources
set
(
MGE_IR_DIR
${
PROJECT_SOURCE_DIR
}
/src/core/include/megbrain/ir
)
set
(
MGE_IR_INCLUDE_DIRS
${
MLIR_LLVM_INCLUDE_DIR
}
${
MGE_GENFILE_DIR
}
${
MGE_IR_DIR
}
)
list
(
TRANSFORM MGE_IR_INCLUDE_DIRS PREPEND
"-I"
)
file
(
GLOB_RECURSE MGE_IR_TDS
${
MGE_IR_DIR
}
/*.td
)
endif
()
if
(
MGE_WITH_DISTRIBUTED
)
add_subdirectory
(
${
PROJECT_SOURCE_DIR
}
/third_party/MegRay
)
endif
()
...
...
src/jit/impl/mlir/ir/CMakeLists.txt
浏览文件 @
d793c87c
...
...
@@ -29,3 +29,11 @@ external_tablegen_library(
-gen-op-decls include/megbrain/jit/mlir/ir/ops.h.inc
-gen-op-defs include/megbrain/jit/mlir/ir/ops.cpp.inc
)
# mgb_dialect
set
(
MGB_DIALECT_TD
${
PROJECT_SOURCE_DIR
}
/src/jit/include/megbrain/jit/mlir/ir/mgb_dialect.td
)
set
(
LLVM_TARGET_DEFINITIONS
${
MGB_DIALECT_TD
}
)
tablegen
(
MLIR mgb_dialect.h.inc
${
MGE_IR_INCLUDE_DIRS
}
"--gen-op-decls"
)
tablegen
(
MLIR mgb_dialect.cpp.inc
${
MGE_IR_INCLUDE_DIRS
}
"--gen-op-defs"
)
add_custom_target
(
mgb_dialect DEPENDS mgb_dialect.h.inc mgb_dialect.cpp.inc
${
MGB_DIALECT_TD
}
${
MGE_IR_TDS
}
)
add_dependencies
(
mgb_dialect param_defs_tblgen
)
src/jit/include/megbrain/jit/mlir/ir/mgb_dialect.td
0 → 100644
浏览文件 @
d793c87c
/**
* \file src/jit/include/megbrain/jit/mlir/ir/mgb_dialect.td
* MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
*
* Copyright (c) 2014-2020 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.
*/
#ifndef MGB_DIALECT
#define MGB_DIALECT
include "ops.td"
class GenericOp<string mnemonic, list<OpTrait> traits = []> :
Op<Mgb_Dialect, mnemonic, traits>;
def ReturnOp : GenericOp<"return",
[NoSideEffect, HasParent<"FuncOp">, Terminator]> {
let summary = "return operation";
let description = [{
The "return" operation represents a return operation within a function.
The operation takes an no tensor operand and produces no results.
}];
// The return operation takes an optional input operand to return. This
// value must match the return type of the enclosing function.
let arguments = (ins);
// The return operation only emits the input in the format if it is present.
let assemblyFormat = "attr-dict";
}
def ConstantScalarOp: GenericOp<"sconst", [NoSideEffect]> {
let summary = "scalar constant";
let arguments = (ins AnyAttr:$value);
let results = (outs F32:$result);
let builders = [OpBuilder<
"Builder* builder, OperationState& result, float value", [{
result.addAttribute("value", builder->getF32FloatAttr(value));
result.addTypes(builder->getF32Type());
}]
>];
let extraClassDeclaration = [{
Attribute getValue() { return getAttr("value"); }
FloatAttr getFloatAttr() { return getAttrOfType<FloatAttr>("value"); }
}];
}
def AssignOp : GenericOp<"assign", []> {
let summary = "assign op";
let description = [{
assign rhs to lhs without results
}];
let arguments = (ins AnyMemRef:$lhs, AnyMemRef:$rhs);
}
#endif // MGB_DIALECT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录