Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
3bd8ef35
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
404
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看板
提交
3bd8ef35
编写于
3月 31, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mgb/compnode): add atlas compnode
GitOrigin-RevId: 19f3c330039c3d0accd9787446c391495f425b6e
上级
aa147b74
变更
20
显示空白变更内容
内联
并排
Showing
20 changed file
with
95 addition
and
30 deletion
+95
-30
CMakeLists.txt
CMakeLists.txt
+9
-0
dnn/include/megcore.h
dnn/include/megcore.h
+1
-0
dnn/src/CMakeLists.txt
dnn/src/CMakeLists.txt
+1
-0
dnn/src/common/megcore/common/device_context.hpp
dnn/src/common/megcore/common/device_context.hpp
+1
-0
dnn/src/common/megcore/public_api/device.cpp
dnn/src/common/megcore/public_api/device.cpp
+7
-0
dnn/test/CMakeLists.txt
dnn/test/CMakeLists.txt
+0
-1
python_module/src/cpp/opr_defs.cpp
python_module/src/cpp/opr_defs.cpp
+1
-0
python_module/src/cpp/opr_defs.h
python_module/src/cpp/opr_defs.h
+2
-0
python_module/src/cpp/opr_helper.h
python_module/src/cpp/opr_helper.h
+0
-1
src/CMakeLists.txt
src/CMakeLists.txt
+1
-2
src/core/impl/comp_node_env.cpp
src/core/impl/comp_node_env.cpp
+2
-2
src/core/impl/graph/var_node_mem_mgr.cpp
src/core/impl/graph/var_node_mem_mgr.cpp
+15
-13
src/core/impl/graph/var_node_mem_mgr.h
src/core/impl/graph/var_node_mem_mgr.h
+4
-4
src/core/include/megbrain/comp_node_env.h
src/core/include/megbrain/comp_node_env.h
+2
-2
src/core/include/megbrain/exception.h
src/core/include/megbrain/exception.h
+0
-1
src/core/test/comp_node.cpp
src/core/test/comp_node.cpp
+0
-3
src/megbrain_build_config.h.in
src/megbrain_build_config.h.in
+1
-0
test/CMakeLists.txt
test/CMakeLists.txt
+1
-0
test/src/helper.cpp
test/src/helper.cpp
+26
-0
test/src/include/megbrain/test/helper.h
test/src/include/megbrain/test/helper.h
+21
-1
未找到文件。
CMakeLists.txt
浏览文件 @
3bd8ef35
...
...
@@ -143,6 +143,15 @@ if(CXX_SUPPORT_GOLD AND NOT ANDROID AND NOT APPLE AND NOT MSVC AND NOT WIN32)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fuse-ld=gold"
)
endif
()
option
(
MGE_WITH_JIT
"Build MegEngine with JIT."
ON
)
option
(
MGE_WITH_HALIDE
"Build MegEngine with Halide JIT"
ON
)
option
(
MGE_DISABLE_FLOAT16
"Disable MegEngine float16 support."
OFF
)
option
(
MGE_WITH_CUDA
"Enable MegEngine CUDA support."
ON
)
option
(
MGE_CUDA_USE_STATIC
"Enable MegEngine CUDA static linking."
ON
)
option
(
MGE_WITH_TRT
"Build MegEngine with TensorRT."
ON
)
option
(
MGE_USE_SYSTEM_LIB
"Build MegEngine with system libraries."
OFF
)
option
(
MGB_WITH_FLATBUFFERS
"Build MegBrain with FlatBuffers serialization support."
ON
)
if
(
NOT MGE_WITH_JIT
)
if
(
MGE_WITH_HALIDE
)
message
(
WARNING
"MGE_WITH_HALIDE is set to OFF with MGE_WITH_JIT disabled"
)
...
...
dnn/include/megcore.h
浏览文件 @
3bd8ef35
...
...
@@ -84,6 +84,7 @@ megcoreStatus_t megcoreGetDeviceFlags(
unsigned
int
*
flags
);
megcoreStatus_t
megcoreActivate
(
megcoreDeviceHandle_t
handle
);
megcoreStatus_t
megcoreDeactivate
(
megcoreDeviceHandle_t
handle
);
megcoreStatus_t
megcoreMalloc
(
megcoreDeviceHandle_t
handle
,
void
**
devPtr
,
size_t
sizeInBytes
);
megcoreStatus_t
megcoreFree
(
megcoreDeviceHandle_t
handle
,
...
...
dnn/src/CMakeLists.txt
浏览文件 @
3bd8ef35
...
...
@@ -86,6 +86,7 @@ if (BUILD_SHARED_LIBS)
else
()
target_link_libraries
(
megdnn PRIVATE
${
MGE_BLAS_LIBS
}
)
endif
()
if
(
CMAKE_THREAD_LIBS_INIT
)
target_link_libraries
(
megdnn PRIVATE Threads::Threads
)
endif
()
...
...
dnn/src/common/megcore/common/device_context.hpp
浏览文件 @
3bd8ef35
...
...
@@ -38,6 +38,7 @@ class DeviceContext {
virtual
size_t
mem_alignment_in_bytes
()
const
noexcept
=
0
;
virtual
void
activate
()
=
0
;
virtual
void
deactivate
()
{}
virtual
void
*
malloc
(
size_t
size_in_bytes
)
=
0
;
virtual
void
free
(
void
*
ptr
)
=
0
;
...
...
dnn/src/common/megcore/public_api/device.cpp
浏览文件 @
3bd8ef35
...
...
@@ -74,6 +74,13 @@ megcoreStatus_t megcoreActivate(megcoreDeviceHandle_t handle)
return
megcoreSuccess
;
}
megcoreStatus_t
megcoreDeactivate
(
megcoreDeviceHandle_t
handle
)
{
megdnn_assert
(
handle
);
handle
->
content
->
deactivate
();
return
megcoreSuccess
;
}
megcoreStatus_t
megcoreMalloc
(
megcoreDeviceHandle_t
handle
,
void
**
devPtr
,
size_t
sizeInBytes
)
{
...
...
dnn/test/CMakeLists.txt
浏览文件 @
3bd8ef35
...
...
@@ -27,7 +27,6 @@ endif()
add_executable
(
megdnn_test
${
SOURCES
}
)
target_link_libraries
(
megdnn_test gtest
)
target_link_libraries
(
megdnn_test megdnn
${
MGE_BLAS_LIBS
}
)
...
...
python_module/src/cpp/opr_defs.cpp
浏览文件 @
3bd8ef35
...
...
@@ -246,6 +246,7 @@ SymbolVarArray _Opr::tensor_rt_runtime(const SymbolVarArray& inputs,
}
#endif
SymbolVar
_Opr
::
timestamp
(
SymbolVar
input
,
PyObject
*
dest
,
size_t
dest_off
,
const
OperatorNodeConfig
&
config
)
{
auto
tensor
=
std
::
make_shared
<
HostTensorND
>
(
...
...
python_module/src/cpp/opr_defs.h
浏览文件 @
3bd8ef35
...
...
@@ -118,6 +118,8 @@ static SymbolVarArray tensor_rt_runtime(const SymbolVarArray& inputs,
PyObject
*
data_bytes
,
const
OperatorNodeConfig
&
config
);
static
SymbolVar
timestamp
(
SymbolVar
input
,
PyObject
*
dest
,
size_t
dest_off
,
const
OperatorNodeConfig
&
config
);
...
...
python_module/src/cpp/opr_helper.h
浏览文件 @
3bd8ef35
...
...
@@ -18,7 +18,6 @@
#if MGB_ENABLE_OPR_MM
#include "megbrain/opr/collective_comm.h"
#endif
using
AxisIndexer
=
mgb
::
opr
::
indexing
::
AxisIndexer
;
/*!
...
...
src/CMakeLists.txt
浏览文件 @
3bd8ef35
...
...
@@ -124,7 +124,6 @@ if (MGB_WITH_FLATBUFFERS)
target_include_directories
(
megbrain PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
/serialization/include
)
target_compile_definitions
(
megbrain PUBLIC MGB_ENABLE_FBS_SERIALIZATION=1
)
target_link_libraries
(
megbrain PUBLIC flatbuffers
)
set
(
GENERATED_FLATBUFFERS_CONVERTER_PATH
${
CMAKE_CURRENT_BINARY_DIR
}
/genfiles
)
set
(
GEN_FLATBUFFERS_CONVERTER_PY
${
PROJECT_SOURCE_DIR
}
/dnn/scripts/gen_flatbuffers_converter.py
)
file
(
MAKE_DIRECTORY
${
GENERATED_FLATBUFFERS_CONVERTER_PATH
}
)
...
...
src/core/impl/comp_node_env.cpp
浏览文件 @
3bd8ef35
...
...
@@ -96,7 +96,7 @@ megcore::AsyncErrorInfo* MegDNNHandle::make_async_error_info(
cn
.
free_device
(
ptr
);
}
};
megcore
::
AsyncErrorInfo
zero_info
{
0
,
nullptr
,
""
,
{
0
,
0
,
0
,
0
}};
megcore
::
AsyncErrorInfo
zero_info
{
0
,
nullptr
,
""
,
{
0
,
0
,
0
,
0
}};
auto
ptr
=
static_cast
<
megcore
::
AsyncErrorInfo
*>
(
env
.
comp_node
().
alloc_device
(
sizeof
(
zero_info
)));
cn
.
copy_to_device
(
ptr
,
&
zero_info
,
sizeof
(
zero_info
));
...
...
@@ -106,7 +106,7 @@ megcore::AsyncErrorInfo* MegDNNHandle::make_async_error_info(
}
#endif
/* =================== misc =================== */
/* =================== misc =================== */
#if MGB_CUDA
...
...
src/core/impl/graph/var_node_mem_mgr.cpp
浏览文件 @
3bd8ef35
...
...
@@ -123,9 +123,9 @@ StaticDeviceMemoryManager::make_default_impl() {
}
#endif // MGB_THREAD_SAFE
/* ====================
CUDA
AsyncVarReleaser ==================== */
/* ==================== AsyncVarReleaser ==================== */
#if MGB_CUDA
class
VarNodeMemManager
::
CUDA
AsyncVarReleaser
{
class
VarNodeMemManager
::
AsyncVarReleaser
{
struct
WaiterParam
{
CompNode
cn
;
CompNode
::
Event
*
event
;
...
...
@@ -133,10 +133,10 @@ class VarNodeMemManager::CUDAAsyncVarReleaser {
};
class
Waiter
final
:
public
AsyncQueueSC
<
WaiterParam
,
Waiter
>
{
CUDA
AsyncVarReleaser
*
m_par_releaser
;
AsyncVarReleaser
*
m_par_releaser
;
public:
Waiter
(
CUDA
AsyncVarReleaser
*
releaser
)
:
Waiter
(
AsyncVarReleaser
*
releaser
)
:
m_par_releaser
(
releaser
)
{
}
...
...
@@ -159,7 +159,7 @@ class VarNodeMemManager::CUDAAsyncVarReleaser {
Spinlock
m_event_pool_lock
;
public:
~
CUDA
AsyncVarReleaser
()
{
~
AsyncVarReleaser
()
{
wait_release_finish
();
}
...
...
@@ -248,14 +248,15 @@ VarNodeMemManager::VarNodeMemManager(ComputingGraphImpl *graph):
m_owner_graph
(
graph
),
m_seq_mem_opt
(
graph
)
#if MGB_CUDA
,
m_
cuda_asyn_var_releaser
(
new
CUDA
AsyncVarReleaser
)
,
m_
asyn_var_releaser
(
new
AsyncVarReleaser
)
#endif
{
auto
on_comp_seq_finish
=
[
this
](
const
event
::
CompSeqExecFinished
&
ev
)
{
MGB_MARK_USED_VAR
(
ev
);
// async release is only used for sync between multiple comp nodes, and
// does not wait for device to finish
#if MGB_CUDA
m_
cuda_
asyn_var_releaser
->
wait_release_finish
();
m_asyn_var_releaser
->
wait_release_finish
();
#endif
m_cpu_async_release_barrier
.
wait_zero
();
};
...
...
@@ -295,9 +296,10 @@ VarNodeMemManager::VarNodeMemManager(ComputingGraphImpl *graph):
graph
->
event
().
register_receiver_permanent
<
event
::
CompSeqExecError
>
(
on_comp_seq_error
);
#if MGB_ENABLE_VAR_DEV_MEM_DEFRAGMENTER
#if MGB_ENABLE_VAR_DEV_MEM_DEFRAGMENTER && (MGB_CUDA \
)
auto
on_mem_defrag_start
=
[
this
](
const
event
::
BeforeMemDefrag
&
)
{
m_
cuda_
asyn_var_releaser
->
wait_release_finish
();
m_asyn_var_releaser
->
wait_release_finish
();
};
graph
->
event
().
register_receiver_permanent
<
event
::
BeforeMemDefrag
>
(
on_mem_defrag_start
);
...
...
@@ -1341,7 +1343,7 @@ void VarNodeMemManager::decr_var_mem_refcnt(
}
#if MGB_CUDA
case
DT
::
CUDA
:
m_
cuda_
asyn_var_releaser
->
add
(
dispatch_cn
,
var
);
m_asyn_var_releaser
->
add
(
dispatch_cn
,
var
);
break
;
#endif
default:
...
...
src/core/impl/graph/var_node_mem_mgr.h
浏览文件 @
3bd8ef35
...
...
@@ -432,9 +432,9 @@ class VarNodeMemManager {
#if MGB_CUDA
//! release dynamic var on after c
uda
event finishes
class
CUDA
AsyncVarReleaser
;
std
::
unique_ptr
<
CUDAAsyncVarReleaser
>
m_cuda
_asyn_var_releaser
;
//! release dynamic var on after c
ompnode
event finishes
class
AsyncVarReleaser
;
std
::
unique_ptr
<
AsyncVarReleaser
>
m
_asyn_var_releaser
;
#endif
VarDevMemDefragmenter
m_var_dev_mem_defragmenter
{
this
};
...
...
src/core/include/megbrain/comp_node_env.h
浏览文件 @
3bd8ef35
...
...
@@ -41,9 +41,9 @@
} \
} while (0)
#endif // MGB_ENABLE_LOGGING
#endif //MGB_ENABLE_LOGGING
#endif //MGB_CUDA
#endif
//! whether to enable asynchronous initialization for CompNode and CompNodeEnv
#define MGB_ENABLE_COMP_NODE_ASYNC_INIT (MGB_CUDA)
...
...
src/core/include/megbrain/exception.h
浏览文件 @
3bd8ef35
...
...
@@ -136,7 +136,6 @@ public:
* error message
*/
static
std
::
string
get_cuda_extra_info
();
CudaError
(
const
std
::
string
&
msg
);
};
...
...
src/core/test/comp_node.cpp
浏览文件 @
3bd8ef35
...
...
@@ -59,9 +59,6 @@ TEST(TestCompNode, Parse) {
ASSERT_THROW
(
L
::
parse
(
"cpu0:"
),
MegBrainError
);
ASSERT_THROW
(
L
::
parse
(
"cpu0:x"
),
MegBrainError
);
ASSERT_THROW
(
L
::
parse
(
"cpu2:23x"
),
MegBrainError
);
ASSERT_THROW
(
L
::
parse
(
"heaxgon0"
),
MegBrainError
);
ASSERT_THROW
(
L
::
parse
(
"rcom0"
),
MegBrainError
);
ASSERT_THROW
(
L
::
parse
(
"cmabricon0"
),
MegBrainError
);
ASSERT_THROW
(
L
::
parse
(
"multithread"
),
MegBrainError
);
ASSERT_THROW
(
L
::
parse
(
"multithread1:"
),
MegBrainError
);
ASSERT_THROW
(
L
::
parse
(
"multithread1:default"
),
MegBrainError
);
...
...
src/megbrain_build_config.h.in
浏览文件 @
3bd8ef35
...
...
@@ -53,6 +53,7 @@
#cmakedefine01 MEGDNN_THREADS_512
#cmakedefine01 MEGDNN_ENABLE_MULTI_THREADS
// whether cuda is available
#ifndef MGB_CUDA
#define MGB_CUDA 1
...
...
test/CMakeLists.txt
浏览文件 @
3bd8ef35
...
...
@@ -15,6 +15,7 @@ if (MGE_WITH_CUDA AND MGE_WITH_TRT)
list
(
APPEND SOURCES
${
SOURCES_
}
)
endif
()
add_executable
(
megbrain_test
${
SOURCES
}
)
target_link_libraries
(
megbrain_test gtest
)
target_link_libraries
(
megbrain_test megengine
)
...
...
test/src/helper.cpp
浏览文件 @
3bd8ef35
...
...
@@ -98,22 +98,48 @@ dtype, RandomDistribution::UNIFORM>::operator ()(
return
ret
;
}
template
<
typename
dtype
>
std
::
shared_ptr
<
HostTensorND
>
HostTensorGenerator
<
dtype
,
RandomDistribution
::
CONSTANT
>::
operator
()(
const
TensorShape
&
shape
,
CompNode
cn
)
{
if
(
!
cn
.
valid
())
cn
=
CompNode
::
load
(
"xpu0"
);
std
::
shared_ptr
<
HostTensorND
>
ret
=
std
::
make_shared
<
HostTensorND
>
(
cn
,
shape
,
dtype
());
auto
ptr
=
ret
->
ptr
<
ctype
>
();
for
(
size_t
i
=
0
,
it
=
shape
.
total_nr_elems
();
i
<
it
;
++
i
)
{
ptr
[
i
]
=
m_default_val
;
}
return
ret
;
}
// explicit instantialization of HostTensorGenerator
namespace
mgb
{
template
class
HostTensorGenerator
<
dtype
::
Float32
,
RandomDistribution
::
GAUSSIAN
>;
template
class
HostTensorGenerator
<
dtype
::
Float32
,
RandomDistribution
::
UNIFORM
>;
template
class
HostTensorGenerator
<
dtype
::
Float32
,
RandomDistribution
::
CONSTANT
>;
template
class
HostTensorGenerator
<
dtype
::
Float16
,
RandomDistribution
::
GAUSSIAN
>;
template
class
HostTensorGenerator
<
dtype
::
Int8
,
RandomDistribution
::
UNIFORM
>;
template
class
HostTensorGenerator
<
dtype
::
Int8
,
RandomDistribution
::
CONSTANT
>;
template
class
HostTensorGenerator
<
dtype
::
Uint8
,
RandomDistribution
::
UNIFORM
>;
template
class
HostTensorGenerator
<
dtype
::
Uint8
,
RandomDistribution
::
CONSTANT
>;
template
class
HostTensorGenerator
<
dtype
::
Int16
,
RandomDistribution
::
UNIFORM
>;
template
class
HostTensorGenerator
<
dtype
::
Int16
,
RandomDistribution
::
CONSTANT
>;
template
class
HostTensorGenerator
<
dtype
::
Int32
,
RandomDistribution
::
UNIFORM
>;
template
class
HostTensorGenerator
<
dtype
::
Int32
,
RandomDistribution
::
CONSTANT
>;
std
::
shared_ptr
<
HostTensorND
>
HostTensorGenerator
<
dtype
::
QuantizedS8
,
RandomDistribution
::
UNIFORM
>::
operator
()(
const
TensorShape
&
shape
,
CompNode
cn
)
{
...
...
test/src/include/megbrain/test/helper.h
浏览文件 @
3bd8ef35
...
...
@@ -175,7 +175,7 @@ class RNGxorshf {
};
enum
class
RandomDistribution
{
GAUSSIAN
,
UNIFORM
GAUSSIAN
,
UNIFORM
,
CONSTANT
};
template
<
class
dtype
>
...
...
@@ -322,6 +322,26 @@ class HostTensorGenerator<dtype, RandomDistribution::UNIFORM> final:
ctype
m_lo
,
m_hi
;
};
//! const value
template
<
class
dtype
>
class
HostTensorGenerator
<
dtype
,
RandomDistribution
::
CONSTANT
>
final
:
public
HostTensorGeneratorBase
{
public:
using
ctype
=
typename
DTypeTrait
<
dtype
>::
ctype
;
HostTensorGenerator
(
ctype
default_val
)
:
HostTensorGeneratorBase
{
next_rand_seed
()},
m_default_val
{
default_val
}
{}
std
::
shared_ptr
<
HostTensorND
>
operator
()(
const
TensorShape
&
shape
,
CompNode
cn
=
{})
override
;
using
HostTensorGeneratorBase
::
operator
();
private:
ctype
m_default_val
;
};
template
<
>
class
HostTensorGenerator
<
dtype
::
QuantizedS8
,
RandomDistribution
::
UNIFORM
>
final
:
public
HostTensorGeneratorBase
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录