Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
939bf3b2
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
410
Star
4707
Fork
583
代码
文件
提交
分支
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看板
提交
939bf3b2
编写于
9月 04, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mge/imperative): impl hashable for nms and cond_take
GitOrigin-RevId: 56918db014326fb8c317119039585f2f3707e8e3
上级
8dc23e0f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
0 deletion
+41
-0
imperative/python/test/unit/functional/test_functional.py
imperative/python/test/unit/functional/test_functional.py
+18
-0
imperative/src/include/megbrain/imperative/ops/cond_take.h
imperative/src/include/megbrain/imperative/ops/cond_take.h
+9
-0
imperative/src/include/megbrain/imperative/ops/nms.h
imperative/src/include/megbrain/imperative/ops/nms.h
+14
-0
未找到文件。
imperative/python/test/unit/functional/test_functional.py
浏览文件 @
939bf3b2
...
...
@@ -11,6 +11,7 @@ import itertools
import
numpy
as
np
import
pytest
import
megengine.core.ops.builtin
as
builtin
import
megengine.core.tensor.dtype
as
dtype
import
megengine.functional
as
F
from
megengine
import
Buffer
,
Parameter
,
is_cuda_available
,
tensor
...
...
@@ -631,3 +632,20 @@ def test_condtake():
val
,
idx
=
F
.
cond_take
(
yy
,
xx
)
np
.
testing
.
assert_equal
(
val
.
numpy
(),
x
[
y
])
np
.
testing
.
assert_equal
(
idx
.
numpy
(),
np
.
where
(
y
.
reshape
(
-
1
))[
0
])
def
test_condtake_is_same
():
op1
=
builtin
.
CondTake
()
op2
=
builtin
.
CondTake
()
assert
op1
==
op2
def
test_nms_is_same
():
op1
=
builtin
.
NMSKeep
(
0.7
,
100
)
op2
=
builtin
.
NMSKeep
(
0.7
,
100
)
op3
=
builtin
.
NMSKeep
(
0.8
,
100
)
op4
=
builtin
.
NMSKeep
(
0.7
,
200
)
assert
op1
==
op2
assert
op1
!=
op3
assert
op1
!=
op4
assert
op3
!=
op4
imperative/src/include/megbrain/imperative/ops/cond_take.h
浏览文件 @
939bf3b2
...
...
@@ -19,6 +19,15 @@ class CondTake : public OpDefImplBase<CondTake> {
MGB_DYN_TYPE_OBJ_FINAL_DECL
;
public:
CondTake
()
=
default
;
size_t
hash
()
const
override
{
return
reinterpret_cast
<
std
::
uintptr_t
>
(
dyn_typeinfo
());
}
bool
is_same_st
(
const
Hashable
&
rhs
)
const
override
{
return
rhs
.
dyn_typeinfo
()
==
dyn_typeinfo
();
}
};
}
// namespace mgb::imperative
imperative/src/include/megbrain/imperative/ops/nms.h
浏览文件 @
939bf3b2
...
...
@@ -23,6 +23,20 @@ public:
NMSKeep
()
=
default
;
NMSKeep
(
float
iou_thresh_
,
uint32_t
max_output_
)
:
iou_thresh
(
iou_thresh_
),
max_output
(
max_output_
)
{}
size_t
hash
()
const
override
{
return
hash_pair_combine
(
hash_pair_combine
(
mgb
::
hash
(
iou_thresh
),
mgb
::
hash
(
max_output
)),
reinterpret_cast
<
std
::
uintptr_t
>
(
dyn_typeinfo
()));
}
bool
is_same_st
(
const
Hashable
&
rhs_
)
const
override
{
auto
&&
rhs
=
static_cast
<
const
NMSKeep
&>
(
rhs_
);
return
rhs
.
dyn_typeinfo
()
==
dyn_typeinfo
()
&&
rhs
.
iou_thresh
==
iou_thresh
&&
rhs
.
max_output
==
max_output
;
}
};
}
// namespace mgb::imperative
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录