Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
4d22e85b
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,发现更多精彩内容 >>
提交
4d22e85b
编写于
6月 10, 2022
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(ci): add completeness compatibility check
GitOrigin-RevId: a7f75c4c5e9794c5ea201912c36cc6a7c95361b4
上级
f7b03959
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
78 addition
and
11 deletion
+78
-11
src/serialization/impl/opr_registry.cpp
src/serialization/impl/opr_registry.cpp
+70
-4
src/serialization/impl/serializer_oss.cpp
src/serialization/impl/serializer_oss.cpp
+1
-0
src/serialization/impl/serializer_oss_v2.cpp
src/serialization/impl/serializer_oss_v2.cpp
+1
-0
src/serialization/include/megbrain/serialization/opr_registry.h
...rialization/include/megbrain/serialization/opr_registry.h
+6
-7
未找到文件。
src/serialization/impl/opr_registry.cpp
浏览文件 @
4d22e85b
...
...
@@ -25,6 +25,11 @@ struct StaticData {
//! load/shallow copy and version_type_reg_map is used for Operator dump
ThinHashMap
<
uint8_t
,
ThinHashMap
<
size_t
,
OprRegistryV2
>>
version_id_reg_map
;
ThinHashMap
<
uint8_t
,
ThinHashMap
<
Typeinfo
*
,
OprRegistryV2
*>>
version_type_reg_map
;
#if MGB_ENABLE_DEBUG_UTIL
std
::
unordered_map
<
size_t
,
std
::
unordered_map
<
size_t
,
std
::
string
>>
dumped_opr
;
MGB_MUTEX
g_record_map_mtx
;
bool
recorded
=
false
;
#endif
};
StaticData
&
static_data
()
{
...
...
@@ -235,17 +240,78 @@ void OprRegistry::add_using_dynamic_loader(
}
#if MGB_ENABLE_DEBUG_UTIL
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>
OprRegistry
::
dump_registries
()
{
std
::
vector
<
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>>
OprRegistry
::
dump_registries
()
{
auto
&&
id2reg
=
static_data
().
id2reg
;
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>
result
;
std
::
vector
<
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>>
result
;
//! version 1 is old register, version 2 is registerV2
result
.
resize
(
CURRENT_VERSION
+
1
);
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>
old_version
;
for
(
auto
iter
=
id2reg
.
begin
();
iter
!=
id2reg
.
end
();
++
iter
)
{
if
(
iter
->
second
.
name
.
size
()
==
0
)
result
.
push_back
({
iter
->
first
,
"<special>"
});
old_version
.
push_back
(
std
::
make_pair
(
iter
->
first
,
"<special>"
));
else
old_version
.
push_back
(
std
::
make_pair
(
iter
->
first
,
iter
->
second
.
name
));
}
result
[
VERSION_1
]
=
old_version
;
auto
&&
version_id_reg_map
=
static_data
().
version_id_reg_map
;
for
(
int
version_id
=
CURRENT_VERSION
;
version_id
>
1
;
version_id
--
)
{
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>
version_opr
;
auto
&&
version_map
=
version_id_reg_map
[
version_id
];
for
(
auto
&&
it
:
version_map
)
{
if
(
it
.
second
.
name
.
size
()
==
0
)
version_opr
.
push_back
(
std
::
make_pair
(
it
.
first
,
"<special>"
));
else
version_opr
.
push_back
(
std
::
make_pair
(
it
.
first
,
it
.
second
.
name
));
}
result
[
version_id
]
=
version_opr
;
}
return
result
;
}
std
::
vector
<
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>>
OprRegistry
::
recorded_serialized_oprs
(
bool
begin_record
,
bool
end_record
)
{
MGB_LOCK_GUARD
(
static_data
().
g_record_map_mtx
);
if
(
begin_record
)
{
static_data
().
recorded
=
true
;
return
{};
}
if
(
end_record
)
{
static_data
().
recorded
=
false
;
std
::
vector
<
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>>
result
;
result
.
resize
(
CURRENT_VERSION
+
1
);
auto
&
recorded
=
static_data
().
dumped_opr
;
for
(
int
version_id
=
CURRENT_VERSION
;
version_id
>
0
;
version_id
--
)
{
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>
version_opr
;
auto
&&
version_map
=
recorded
[
version_id
];
for
(
auto
&&
it
:
version_map
)
{
if
(
it
.
second
.
size
()
==
0
)
version_opr
.
push_back
(
std
::
make_pair
(
it
.
first
,
"<special>"
));
else
result
.
push_back
({
iter
->
first
,
iter
->
second
.
name
});
version_opr
.
push_back
(
std
::
make_pair
(
it
.
first
,
it
.
second
));
}
result
[
version_id
]
=
version_opr
;
}
static_data
().
dumped_opr
.
clear
();
return
result
;
}
return
{};
}
void
mgb
::
serialization
::
record_opr_dumped
(
const
size_t
id
,
std
::
string
name
,
int
version
)
{
if
(
static_data
().
recorded
)
{
MGB_LOCK_GUARD
(
static_data
().
g_record_map_mtx
);
auto
&
opr_dumped
=
static_data
().
dumped_opr
;
if
(
name
.
size
()
==
0
)
opr_dumped
[
version
][
id
]
=
"<special>"
;
else
opr_dumped
[
version
][
id
]
=
name
;
}
}
#else
void
mgb
::
serialization
::
record_opr_dumped
(
const
size_t
,
std
::
string
,
int
)
{}
#endif
namespace
{
...
...
src/serialization/impl/serializer_oss.cpp
浏览文件 @
4d22e85b
...
...
@@ -307,6 +307,7 @@ GraphDumper::DumpResult GraphDumperOSS::dump(
init_oprs_to_dump
(
output_vars
);
std
::
vector
<
flatbuffers
::
Offset
<
fbs
::
Operator
>>
oprs
;
for
(
auto
&&
i
:
m_oprs_to_dump
)
{
record_opr_dumped
(
i
.
second
->
persist_type_id
,
i
.
second
->
name
,
0
);
oprs
.
emplace_back
(
build_single_opr
(
i
.
first
,
i
.
second
));
}
auto
fb_oprs
=
m_builder
.
CreateVector
(
oprs
);
...
...
src/serialization/impl/serializer_oss_v2.cpp
浏览文件 @
4d22e85b
...
...
@@ -394,6 +394,7 @@ GraphDumper::DumpResult GraphDumperOSSV2::dump(
init_oprs_to_dump
(
new_output_vars
);
std
::
vector
<
flatbuffers
::
Offset
<
fbs
::
v2
::
Operator
>>
oprs
;
for
(
auto
&&
i
:
m_oprs_to_dump
)
{
record_opr_dumped
(
i
.
second
->
type_id
,
i
.
second
->
name
,
i
.
second
->
version
);
oprs
.
emplace_back
(
build_single_opr
(
i
.
first
,
i
.
second
));
}
auto
fb_oprs
=
m_builder
.
CreateVector
(
oprs
);
...
...
src/serialization/include/megbrain/serialization/opr_registry.h
浏览文件 @
4d22e85b
...
...
@@ -22,6 +22,8 @@ public:
cg
::
OperatorNodeBase
*
opr
()
{
return
m_opr
;
}
};
void
record_opr_dumped
(
const
size_t
id
,
std
::
string
name
,
int
version
);
//! dump opr internal params to OprDumpContext
using
OprDumper
=
thin_function
<
void
(
OprDumpContext
&
ctx
,
const
cg
::
OperatorNodeBase
&
opr
)
>
;
...
...
@@ -83,8 +85,11 @@ struct OprRegistry {
#if MGB_ENABLE_DEBUG_UTIL
//! dump registered oprs
MGE_WIN_DECLSPEC_FUC
static
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>
MGE_WIN_DECLSPEC_FUC
static
std
::
vector
<
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>
>>
dump_registries
();
//! record all dumped/loaded oprs (hash_id --> type)
MGE_WIN_DECLSPEC_FUC
static
std
::
vector
<
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>>
recorded_serialized_oprs
(
bool
begin_record
,
bool
end_record
);
#endif
};
...
...
@@ -113,12 +118,6 @@ struct OprRegistryV2 {
MGE_WIN_DECLSPEC_FUC
static
const
OprRegistryV2
*
versioned_find_by_typeinfo
(
Typeinfo
*
type
,
uint8_t
version
);
#if MGB_ENABLE_DEBUG_UTIL
//! dump registered oprs
MGE_WIN_DECLSPEC_FUC
static
std
::
vector
<
std
::
pair
<
size_t
,
std
::
string
>>
dump_registries
();
#endif
};
}
// namespace serialization
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录