Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
064c774f
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看板
提交
064c774f
编写于
11月 18, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(imperative): impl hashable for SendRecv and add virtual input for Recv
GitOrigin-RevId: 5e8c27ac81b844bbf8720a108da7ad208060dad2
上级
798f7b3e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
89 addition
and
1 deletion
+89
-1
imperative/src/impl/ops/io_remote.cpp
imperative/src/impl/ops/io_remote.cpp
+38
-1
imperative/src/include/megbrain/imperative/ops/io_remote.h
imperative/src/include/megbrain/imperative/ops/io_remote.h
+14
-0
src/opr-mm/impl/io_remote.cpp
src/opr-mm/impl/io_remote.cpp
+26
-0
src/opr-mm/include/megbrain/opr/io_remote.h
src/opr-mm/include/megbrain/opr/io_remote.h
+11
-0
未找到文件。
imperative/src/impl/ops/io_remote.cpp
浏览文件 @
064c774f
...
...
@@ -46,7 +46,7 @@ cg::OperatorNodeBase* apply_on_var_node_remote_recv(
ssprintf
(
"%s:%d"
,
recv
.
addr
.
data
(),
recv
.
port
));
auto
&&
graph
=
inputs
[
0
]
->
owner_graph
();
return
graph
->
insert_opr
(
std
::
make_unique
<
mgb
::
opr
::
RemoteRecv
>
(
recv
.
key
,
*
graph
,
group_client
,
OperatorNodeConfig
{
recv
.
cn
},
recv
.
key
,
inputs
[
0
],
*
graph
,
group_client
,
OperatorNodeConfig
{
recv
.
cn
},
recv
.
shape
,
recv
.
dtype
));
}
...
...
@@ -60,6 +60,43 @@ OP_TRAIT_REG(RemoteRecv, RemoteRecv, mgb::opr::RemoteRecv)
}
// anonymous namespace
#endif // MGB_ENABLE_OPR_MM
bool
RemoteSend
::
is_same_st
(
const
Hashable
&
another
)
const
{
return
as_tuple
()
==
another
.
cast_final
<
RemoteSend
>
().
as_tuple
();
}
size_t
RemoteSend
::
hash
()
const
{
XXHash
xxhash
;
auto
append
=
[
&
xxhash
](
auto
field
){
auto
hash_val
=
HashTrait
<
decltype
(
field
)
>::
eval
(
field
);
xxhash
.
update
(
reinterpret_cast
<
void
*>
(
&
hash_val
),
sizeof
(
hash_val
));
};
append
(
key
);
append
(
addr
);
append
(
port
);
append
(
rank_to
);
return
xxhash
.
digest
();
}
bool
RemoteRecv
::
is_same_st
(
const
Hashable
&
another
)
const
{
return
as_tuple
()
==
another
.
cast_final
<
RemoteRecv
>
().
as_tuple
();
}
size_t
RemoteRecv
::
hash
()
const
{
XXHash
xxhash
;
auto
append
=
[
&
xxhash
](
auto
field
){
auto
hash_val
=
HashTrait
<
decltype
(
field
)
>::
eval
(
field
);
xxhash
.
update
(
reinterpret_cast
<
void
*>
(
&
hash_val
),
sizeof
(
hash_val
));
};
append
(
key
);
append
(
addr
);
append
(
port
);
append
(
rank_from
);
append
(
cn
.
to_string
());
append
(
dtype
.
handle
());
append
(
shape
.
to_string
());
return
xxhash
.
digest
();
}
MGB_DYN_TYPE_OBJ_FINAL_IMPL
(
RemoteSend
);
MGB_DYN_TYPE_OBJ_FINAL_IMPL
(
RemoteRecv
);
...
...
imperative/src/include/megbrain/imperative/ops/io_remote.h
浏览文件 @
064c774f
...
...
@@ -31,6 +31,13 @@ public:
std
::
string
addr
;
uint32_t
port
;
uint32_t
rank_to
;
size_t
hash
()
const
override
;
bool
is_same_st
(
const
Hashable
&
another
)
const
override
;
auto
as_tuple
()
const
{
return
std
::
tuple
(
key
,
addr
,
port
,
rank_to
);
}
};
class
RemoteRecv
:
public
OpDefImplBase
<
RemoteRecv
>
{
...
...
@@ -55,6 +62,13 @@ public:
CompNode
cn
;
TensorShape
shape
;
DType
dtype
;
size_t
hash
()
const
override
;
bool
is_same_st
(
const
Hashable
&
another
)
const
override
;
auto
as_tuple
()
const
{
return
std
::
tuple
(
key
,
addr
,
port
,
rank_from
,
cn
,
dtype
,
shape
.
to_string
());
}
};
}
// namespace imperative
...
...
src/opr-mm/impl/io_remote.cpp
浏览文件 @
064c774f
...
...
@@ -151,6 +151,23 @@ RemoteRecv::RemoteRecv(const std::string& key, cg::ComputingGraph& graph,
add_equivalence_component
<
ScalarHash
<
void
*>>
(
this
);
}
RemoteRecv
::
RemoteRecv
(
const
std
::
string
&
key
,
VarNode
*
var
,
cg
::
ComputingGraph
&
graph
,
std
::
shared_ptr
<
GroupClient
>
group_client
,
const
OperatorNodeConfig
&
config
,
const
TensorShape
&
shape
,
DType
dtype
)
:
Super
(
&
graph
,
config
,
"remote_recv"
,
{}),
m_shape
(
shape
),
m_dtype
(
dtype
)
{
m_key
=
key
;
m_group_client
=
group_client
;
add_input
({
var
});
add_output
(
None
)
->
dtype
(
dtype
)
.
add_flag
(
VarNode
::
Flag
::
NO_MEM_RECLAIM
)
.
add_flag
(
VarNode
::
Flag
::
DISALLOW_RT_FORCE_DYNAMIC_MEM_ALLOC
);
add_equivalence_component
<
ScalarHash
<
void
*>>
(
this
);
}
SymbolVar
RemoteRecv
::
make
(
const
std
::
string
&
key
,
cg
::
ComputingGraph
&
graph
,
std
::
shared_ptr
<
GroupClient
>
group_client
,
const
OperatorNodeConfig
&
config
,
...
...
@@ -160,6 +177,15 @@ SymbolVar RemoteRecv::make(const std::string& key, cg::ComputingGraph& graph,
return
opr
->
output
(
0
);
}
SymbolVar
RemoteRecv
::
make
(
const
std
::
string
&
key
,
SymbolVar
var
,
cg
::
ComputingGraph
&
graph
,
std
::
shared_ptr
<
GroupClient
>
group_client
,
const
OperatorNodeConfig
&
config
,
const
TensorShape
&
shape
,
DType
dtype
)
{
auto
opr
=
graph
.
insert_opr
(
std
::
make_unique
<
RemoteRecv
>
(
key
,
var
.
node
(),
graph
,
group_client
,
config
,
shape
,
dtype
));
return
opr
->
output
(
0
);
}
void
RemoteRecv
::
scn_do_execute
()
{
if
(
!
m_init
)
{
auto
&&
comp_node
=
output
(
0
)
->
comp_node
();
...
...
src/opr-mm/include/megbrain/opr/io_remote.h
浏览文件 @
064c774f
...
...
@@ -77,12 +77,23 @@ MGB_DEFINE_OPR_CLASS(RemoteRecv, RemoteIOBase) // {
const
OperatorNodeConfig
&
config
,
const
TensorShape
&
shape
,
DType
dtype
);
RemoteRecv
(
const
std
::
string
&
key
,
VarNode
*
var
,
cg
::
ComputingGraph
&
graph
,
std
::
shared_ptr
<
GroupClient
>
group_client
,
const
OperatorNodeConfig
&
config
,
const
TensorShape
&
shape
,
DType
dtype
);
static
SymbolVar
make
(
const
std
::
string
&
key
,
cg
::
ComputingGraph
&
graph
,
std
::
shared_ptr
<
GroupClient
>
group_client
,
const
OperatorNodeConfig
&
config
,
const
TensorShape
&
shape
,
DType
dtype
);
static
SymbolVar
make
(
const
std
::
string
&
key
,
SymbolVar
var
,
cg
::
ComputingGraph
&
graph
,
std
::
shared_ptr
<
GroupClient
>
group_client
,
const
OperatorNodeConfig
&
config
,
const
TensorShape
&
shape
,
DType
dtype
);
private
:
const
TensorShape
m_shape
;
const
DType
m_dtype
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录