Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
d0f70a44
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
403
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看板
提交
d0f70a44
编写于
2月 25, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(imperative/utils): module parameters' name do not have scope after dumping
GitOrigin-RevId: 1497272294b125192d2356695259f622eb8d0bc5
上级
b9bbf802
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
18 addition
and
6 deletion
+18
-6
imperative/python/megengine/jit/tracing.py
imperative/python/megengine/jit/tracing.py
+6
-4
imperative/python/megengine/tensor.py
imperative/python/megengine/tensor.py
+1
-1
imperative/python/src/tensor.cpp
imperative/python/src/tensor.cpp
+2
-1
imperative/python/test/unit/functional/test_tensor.py
imperative/python/test/unit/functional/test_tensor.py
+9
-0
未找到文件。
imperative/python/megengine/jit/tracing.py
浏览文件 @
d0f70a44
...
@@ -293,7 +293,9 @@ class trace:
...
@@ -293,7 +293,9 @@ class trace:
h
=
getattr
(
x
,
"_mixin_handle"
,
-
1
)
h
=
getattr
(
x
,
"_mixin_handle"
,
-
1
)
if
h
<
0
or
(
not
self
.
_capture_as_const
and
self
.
_tinfo
[
h
].
exported
):
if
h
<
0
or
(
not
self
.
_capture_as_const
and
self
.
_tinfo
[
h
].
exported
):
h
,
info
=
self
.
_new_handle
()
h
,
info
=
self
.
_new_handle
()
name
=
auto_naming
.
get_scope
()
+
"."
+
x
.
c_name
if
x
.
c_name
else
x
.
_name
name
=
(
auto_naming
.
get_scope
()
+
"."
+
(
x
.
c_name
if
x
.
c_name
else
x
.
_name
)
)
info
.
name
=
name
info
.
name
=
name
info
.
external
=
True
info
.
external
=
True
info
.
device
=
x
.
device
info
.
device
=
x
.
device
...
@@ -1123,11 +1125,11 @@ def apply_symbolic_mode(op: OpDef, *args: RawTensor):
...
@@ -1123,11 +1125,11 @@ def apply_symbolic_mode(op: OpDef, *args: RawTensor):
return
outputs
return
outputs
def
apply_const_symbolic_mode
(
value
,
dtype
,
device
):
def
apply_const_symbolic_mode
(
value
,
dtype
,
device
,
name
):
graph
=
active_trace
.
_lazy_eval_graph
graph
=
active_trace
.
_lazy_eval_graph
# don't need to unset tracing
# don't need to unset tracing
# because varnode construction will ignore tracing flag
# because varnode construction will ignore tracing flag
ret
=
RawTensor
(
graph
.
make_const
(
value
,
dtype
=
dtype
,
device
=
device
))
ret
=
RawTensor
(
graph
.
make_const
(
value
,
dtype
=
dtype
,
device
=
device
,
name
=
name
))
if
np
.
array
(
value
).
ndim
==
0
:
if
np
.
array
(
value
).
ndim
==
0
:
setscalar
(
ret
)
setscalar
(
ret
)
return
(
ret
,)
return
(
ret
,)
...
@@ -1175,7 +1177,7 @@ def apply_with_tracing(op: OpDef, *args: RawTensor):
...
@@ -1175,7 +1177,7 @@ def apply_with_tracing(op: OpDef, *args: RawTensor):
def
apply_const_with_tracing
(
value
,
dtype
,
device
,
is_const
,
no_cache
,
name
):
def
apply_const_with_tracing
(
value
,
dtype
,
device
,
is_const
,
no_cache
,
name
):
if
active_trace
.
_symbolic
:
if
active_trace
.
_symbolic
:
outputs
=
apply_const_symbolic_mode
(
value
,
dtype
,
device
)
outputs
=
apply_const_symbolic_mode
(
value
,
dtype
,
device
,
name
)
else
:
else
:
unset_tracing
()
unset_tracing
()
outputs
=
(
RawTensor
(
value
,
dtype
,
device
,
False
,
name
),)
outputs
=
(
RawTensor
(
value
,
dtype
,
device
,
False
,
name
),)
...
...
imperative/python/megengine/tensor.py
浏览文件 @
d0f70a44
...
@@ -33,7 +33,7 @@ class Tensor(_Tensor, ArrayMethodMixin):
...
@@ -33,7 +33,7 @@ class Tensor(_Tensor, ArrayMethodMixin):
_q_dict
=
None
_q_dict
=
None
def
__new__
(
def
__new__
(
cls
,
data
,
dtype
=
None
,
device
=
None
,
is_const
=
False
,
no_cache
=
False
,
name
=
""
cls
,
data
,
dtype
=
None
,
device
=
None
,
is_const
=
False
,
no_cache
=
False
,
name
=
None
):
):
if
device
is
None
:
if
device
is
None
:
cn
=
get_default_device
()
cn
=
get_default_device
()
...
...
imperative/python/src/tensor.cpp
浏览文件 @
d0f70a44
...
@@ -234,7 +234,8 @@ TensorWrapper::TensorWrapper(PyObject* args, PyObject* kwargs) {
...
@@ -234,7 +234,8 @@ TensorWrapper::TensorWrapper(PyObject* args, PyObject* kwargs) {
CompNode
cn
=
tup
[
2
].
cast
<
CompNode
>
();
CompNode
cn
=
tup
[
2
].
cast
<
CompNode
>
();
bool
is_const
=
tup
[
3
].
cast
<
bool
>
();
bool
is_const
=
tup
[
3
].
cast
<
bool
>
();
bool
no_cache
=
nargs
==
6
?
tup
[
4
].
cast
<
bool
>
()
:
false
;
bool
no_cache
=
nargs
==
6
?
tup
[
4
].
cast
<
bool
>
()
:
false
;
std
::
string
name
=
tup
[
nargs
-
1
].
cast
<
std
::
string
>
();
std
::
string
name
;
if
(
tup
[
nargs
-
1
].
ptr
()
!=
Py_None
)
name
=
tup
[
nargs
-
1
].
cast
<
std
::
string
>
();
// const op
// const op
if
(
is_const
&&
is_tracing
)
{
if
(
is_const
&&
is_tracing
)
{
...
...
imperative/python/test/unit/functional/test_tensor.py
浏览文件 @
d0f70a44
...
@@ -408,6 +408,15 @@ def test_copy_d2d():
...
@@ -408,6 +408,15 @@ def test_copy_d2d():
copy_test
(
"gpu0:0"
,
"gpu0:1"
)
copy_test
(
"gpu0:0"
,
"gpu0:1"
)
def
test_name
():
x
=
tensor
(
0
)
assert
x
.
name
==
""
x
.
name
=
"x"
assert
x
.
name
==
"x"
x
=
tensor
(
0
,
name
=
"x"
)
assert
x
.
name
==
"x"
def
test_q_dict
():
def
test_q_dict
():
x
=
tensor
(
1
)
x
=
tensor
(
1
)
assert
x
.
q_dict
[
"scale"
]
is
None
assert
x
.
q_dict
[
"scale"
]
is
None
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录