Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
43259237
MegEngine
项目概览
MegEngine 天元
/
MegEngine
大约 1 年 前同步成功
通知
396
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,发现更多精彩内容 >>
提交
43259237
编写于
8月 17, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
build(dnn/cuda): fix cmake compile dependency for cutlass kernels
GitOrigin-RevId: ebe71f5a1261ed94904624cd366ff57010357f26
上级
1e3af4dd
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
43 deletion
+33
-43
dnn/scripts/cutlass_generator/conv2d_operation.py
dnn/scripts/cutlass_generator/conv2d_operation.py
+1
-2
dnn/scripts/cutlass_generator/gemm_operation.py
dnn/scripts/cutlass_generator/gemm_operation.py
+2
-3
dnn/scripts/cutlass_generator/lazy_file.py
dnn/scripts/cutlass_generator/lazy_file.py
+0
-27
dnn/scripts/cutlass_generator/manifest.py
dnn/scripts/cutlass_generator/manifest.py
+1
-2
dnn/src/CMakeLists.txt
dnn/src/CMakeLists.txt
+29
-9
未找到文件。
dnn/scripts/cutlass_generator/conv2d_operation.py
浏览文件 @
43259237
...
...
@@ -10,7 +10,6 @@ import os.path
import
shutil
from
typing
import
Tuple
,
List
from
lazy_file
import
LazyFile
from
library
import
*
###################################################################################################
...
...
@@ -584,7 +583,7 @@ void initialize_${operation_name}(Manifest &manifest) {
#
def
__enter__
(
self
):
self
.
kernel_path
=
os
.
path
.
join
(
self
.
kernel_path
,
"%s.cu"
%
self
.
operation
.
procedural_name
())
self
.
kernel_file
=
LazyFile
(
self
.
kernel_path
)
self
.
kernel_file
=
open
(
self
.
kernel_path
,
"w"
)
self
.
kernel_file
.
write
(
self
.
header_template
)
return
self
...
...
dnn/scripts/cutlass_generator/gemm_operation.py
浏览文件 @
43259237
...
...
@@ -10,7 +10,6 @@ import shutil
import
functools
import
operator
from
lazy_file
import
LazyFile
from
library
import
*
...
...
@@ -1045,7 +1044,7 @@ void initialize_${operation_name}(Manifest &manifest) {
#
def
__enter__
(
self
):
self
.
kernel_path
=
os
.
path
.
join
(
self
.
kernel_path
,
"%s.cu"
%
self
.
operation
.
procedural_name
())
self
.
kernel_file
=
LazyFile
(
self
.
kernel_path
)
self
.
kernel_file
=
open
(
self
.
kernel_path
,
"w"
)
self
.
kernel_file
.
write
(
self
.
header_template
)
return
self
...
...
@@ -1109,7 +1108,7 @@ ${operation_instance}
#
def
__enter__
(
self
):
self
.
kernel_path
=
os
.
path
.
join
(
self
.
kernel_path
,
"%s.cu"
%
self
.
operation
.
procedural_name
())
self
.
kernel_file
=
LazyFile
(
self
.
kernel_path
)
self
.
kernel_file
=
open
(
self
.
kernel_path
,
"w"
)
self
.
kernel_file
.
write
(
SubstituteTemplate
(
self
.
header_template
,
{
'wrapper_path'
:
self
.
wrapper_path
,
}))
...
...
dnn/scripts/cutlass_generator/lazy_file.py
已删除
100644 → 0
浏览文件 @
1e3af4dd
#
# \file lazy_file.py
#
# \brief LazyFile updates the target file only when the content is changed
# in order to avoid generating new cutlass kimpls each time cmake is called
#
import
io
import
os
class
LazyFile
:
def
__init__
(
self
,
filename
):
self
.
filename
=
filename
self
.
buffer
=
io
.
StringIO
()
def
write
(
self
,
data
):
self
.
buffer
.
write
(
str
(
data
))
def
close
(
self
):
if
os
.
path
.
isfile
(
self
.
filename
):
old_data
=
open
(
self
.
filename
).
read
()
else
:
old_data
=
""
new_data
=
self
.
buffer
.
getvalue
()
if
old_data
!=
new_data
:
with
open
(
self
.
filename
,
"w"
)
as
f
:
f
.
write
(
new_data
)
dnn/scripts/cutlass_generator/manifest.py
浏览文件 @
43259237
...
...
@@ -8,7 +8,6 @@ import enum
import
os.path
import
shutil
from
lazy_file
import
LazyFile
from
library
import
*
from
gemm_operation
import
*
from
conv2d_operation
import
*
...
...
@@ -353,7 +352,7 @@ void initialize_all(Manifest &manifest) {
def
GenerateManifest
(
args
,
operations
,
output_dir
):
manifest_path
=
os
.
path
.
join
(
output_dir
,
"all_%s_%s_operations.cu"
%
(
args
.
operations
,
args
.
type
))
f
=
LazyFile
(
manifest_path
)
f
=
open
(
manifest_path
,
"w"
)
f
.
write
(
"""
/*
Generated by generator.py - Do not edit.
...
...
dnn/src/CMakeLists.txt
浏览文件 @
43259237
...
...
@@ -116,11 +116,18 @@ if(MGE_WITH_CUDA)
set
(
CUTLASS_GEN_SCRIPT
${
CMAKE_CURRENT_SOURCE_DIR
}
/../scripts/cutlass_generator/generator.py
)
set
(
CUTLASS_GEN_DIR
${
CMAKE_CURRENT_BINARY_DIR
}
/cuda/cutlass/generated
)
function
(
gen_cutlass_kimpl op type
)
set
(
CUTLASS_SOURCES
""
)
function
(
gen_cutlass_kimpl op type gen_files
)
set
(
CURRENT_CUTLASS_STAGE_DIR
${
CUTLASS_GEN_DIR
}
/
${
op
}
_
${
type
}
.stage
)
set
(
CURRENT_CUTLASS_GEN_DIR
${
CUTLASS_GEN_DIR
}
/
${
op
}
_
${
type
}
)
set_directory_properties
(
PROPERTIES CMAKE_CONFIGURE_DEPENDS
${
CUTLASS_GEN_SCRIPT
}
)
file
(
REMOVE_RECURSE
${
CURRENT_CUTLASS_STAGE_DIR
}
)
file
(
MAKE_DIRECTORY
${
CURRENT_CUTLASS_STAGE_DIR
}
)
file
(
MAKE_DIRECTORY
${
CURRENT_CUTLASS_GEN_DIR
}
)
execute_process
(
COMMAND
${
PYTHON3_EXECUTABLE_WITHOUT_VERSION
}
${
CUTLASS_GEN_SCRIPT
}
--operations
${
op
}
--type
${
type
}
${
CURRENT_CUTLASS_
GEN
_DIR
}
COMMAND
${
PYTHON3_EXECUTABLE_WITHOUT_VERSION
}
${
CUTLASS_GEN_SCRIPT
}
--operations
${
op
}
--type
${
type
}
${
CURRENT_CUTLASS_
STAGE
_DIR
}
RESULT_VARIABLE gen_cutlass_result
OUTPUT_FILE
${
CURRENT_CUTLASS_GEN_DIR
}
/gen_cutlass.log
ERROR_FILE
${
CURRENT_CUTLASS_GEN_DIR
}
/gen_cutlass.log
...
...
@@ -128,14 +135,27 @@ if(MGE_WITH_CUDA)
if
(
NOT gen_cutlass_result EQUAL 0
)
message
(
FATAL_ERROR
"Error generating library instances. See
${
CURRENT_CUTLASS_GEN_DIR
}
/gen_cutlass.log"
)
endif
()
file
(
GLOB CUTLASS_GEN_FILES RELATIVE
"
${
CURRENT_CUTLASS_GEN_DIR
}
/"
"
${
CURRENT_CUTLASS_GEN_DIR
}
/*.cu"
)
foreach
(
FILE
${
CUTLASS_GEN_FILES
}
)
if
(
NOT EXISTS
"
${
CURRENT_CUTLASS_STAGE_DIR
}
/
${
FILE
}
"
)
file
(
REMOVE
"
${
CURRENT_CUTLASS_GEN_DIR
}
/
${
FILE
}
"
)
endif
()
endforeach
()
file
(
GLOB CUTLASS_GEN_FILES RELATIVE
"
${
CURRENT_CUTLASS_STAGE_DIR
}
"
"
${
CURRENT_CUTLASS_STAGE_DIR
}
/*.cu"
)
foreach
(
FILE
${
CUTLASS_GEN_FILES
}
)
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
"
${
CURRENT_CUTLASS_STAGE_DIR
}
/
${
FILE
}
"
"
${
CURRENT_CUTLASS_GEN_DIR
}
"
)
endforeach
()
file
(
REMOVE_RECURSE
${
CURRENT_CUTLASS_STAGE_DIR
}
)
file
(
GLOB_RECURSE CUTLASS_GEN_FILES
"
${
CURRENT_CUTLASS_GEN_DIR
}
/*.cu"
)
list
(
APPEND
${
gen_files
}
${
CUTLASS_GEN_FILES
}
)
set
(
${
gen_files
}
"
${${
gen_files
}}
"
PARENT_SCOPE
)
endfunction
()
gen_cutlass_kimpl
(
gemm simt
)
gen_cutlass_kimpl
(
gemv simt
)
gen_cutlass_kimpl
(
deconv simt
)
gen_cutlass_kimpl
(
conv2d simt
)
gen_cutlass_kimpl
(
conv2d tensorop8816
)
gen_cutlass_kimpl
(
conv2d tensorop8832
)
file
(
GLOB_RECURSE CUTLASS_SOURCES
${
CUTLASS_GEN_DIR
}
/*.cu
)
gen_cutlass_kimpl
(
gemm simt CUTLASS_SOURCES
)
gen_cutlass_kimpl
(
gemv simt CUTLASS_SOURCES
)
gen_cutlass_kimpl
(
deconv simt CUTLASS_SOURCES
)
gen_cutlass_kimpl
(
conv2d simt CUTLASS_SOURCES
)
gen_cutlass_kimpl
(
conv2d tensorop8816 CUTLASS_SOURCES
)
gen_cutlass_kimpl
(
conv2d tensorop8832 CUTLASS_SOURCES
)
list
(
APPEND SOURCES
${
CUTLASS_SOURCES
}
)
list
(
APPEND SOURCES
${
CUSOURCES
}
)
endif
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录