Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
30095514
MegEngine
项目概览
MegEngine 天元
/
MegEngine
接近 2 年 前同步成功
通知
414
Star
4708
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看板
提交
30095514
编写于
10月 08, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(traced_module/doc): fix warning for traced_module docstring
GitOrigin-RevId: 5d2d047d2fb226d629ab5e18d9d5221d27289c6a
上级
4cb7fa8e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
11 addition
and
18 deletion
+11
-18
imperative/python/megengine/traced_module/expr.py
imperative/python/megengine/traced_module/expr.py
+2
-2
imperative/python/megengine/traced_module/node.py
imperative/python/megengine/traced_module/node.py
+4
-11
imperative/python/megengine/traced_module/pytree.py
imperative/python/megengine/traced_module/pytree.py
+3
-3
imperative/python/megengine/traced_module/traced_module.py
imperative/python/megengine/traced_module/traced_module.py
+2
-2
未找到文件。
imperative/python/megengine/traced_module/expr.py
浏览文件 @
30095514
...
@@ -159,13 +159,13 @@ class Expr:
...
@@ -159,13 +159,13 @@ class Expr:
@
property
@
property
def
kwargs
(
self
):
def
kwargs
(
self
):
r
"""Get the
the
keyword arguments of the operation corresponding to this Expr."""
r
"""Get the keyword arguments of the operation corresponding to this Expr."""
_
,
kwargs
=
self
.
unflatten_args
(
self
.
inputs
)
_
,
kwargs
=
self
.
unflatten_args
(
self
.
inputs
)
return
kwargs
return
kwargs
@
property
@
property
def
args
(
self
):
def
args
(
self
):
r
"""Get the
the
positional arguments of the operation corresponding to this Expr."""
r
"""Get the positional arguments of the operation corresponding to this Expr."""
args
,
_
=
self
.
unflatten_args
(
self
.
inputs
)
args
,
_
=
self
.
unflatten_args
(
self
.
inputs
)
return
args
return
args
...
...
imperative/python/megengine/traced_module/node.py
浏览文件 @
30095514
...
@@ -33,7 +33,7 @@ class Node:
...
@@ -33,7 +33,7 @@ class Node:
_orig_name
=
None
# type: str
_orig_name
=
None
# type: str
_format_spec
=
""
# type: str
_format_spec
=
""
# type: str
def
__init__
(
self
,
expr
:
"Expr"
,
name
:
str
,
orig_name
:
str
):
def
__init__
(
self
,
expr
,
name
:
str
,
orig_name
:
str
):
self
.
expr
=
expr
self
.
expr
=
expr
self
.
users
=
[]
# List[Expr]
self
.
users
=
[]
# List[Expr]
self
.
_id
=
Node
.
__total_id
self
.
_id
=
Node
.
__total_id
...
@@ -120,7 +120,7 @@ class ModuleNode(Node):
...
@@ -120,7 +120,7 @@ class ModuleNode(Node):
r
"""The type of the Module correspending to the ModuleNode."""
r
"""The type of the Module correspending to the ModuleNode."""
_owner
=
None
# type: weakref.ReferenceType
_owner
=
None
# type: weakref.ReferenceType
def
__init__
(
self
,
expr
:
"Expr"
,
name
:
str
=
None
,
orig_name
:
str
=
None
):
def
__init__
(
self
,
expr
,
name
:
str
=
None
,
orig_name
:
str
=
None
):
super
().
__init__
(
expr
,
name
,
orig_name
)
super
().
__init__
(
expr
,
name
,
orig_name
)
def
__getstate__
(
self
):
def
__getstate__
(
self
):
...
@@ -136,9 +136,6 @@ class ModuleNode(Node):
...
@@ -136,9 +136,6 @@ class ModuleNode(Node):
@
property
@
property
def
owner
(
self
):
def
owner
(
self
):
r
"""Get the ``Module`` corresponding to this ``ModuleNode``.
r
"""Get the ``Module`` corresponding to this ``ModuleNode``.
Returns:
An :calss:`~.Module`.
"""
"""
if
self
.
_owner
:
if
self
.
_owner
:
return
self
.
_owner
()
return
self
.
_owner
()
...
@@ -196,7 +193,7 @@ class TensorNode(Node):
...
@@ -196,7 +193,7 @@ class TensorNode(Node):
@
property
@
property
def
qparams
(
self
):
def
qparams
(
self
):
r
"""Get the :c
al
ss:`QParams` of this Node."""
r
"""Get the :c
la
ss:`QParams` of this Node."""
return
self
.
_qparams
return
self
.
_qparams
@
qparams
.
setter
@
qparams
.
setter
...
@@ -210,11 +207,7 @@ class TensorNode(Node):
...
@@ -210,11 +207,7 @@ class TensorNode(Node):
@
value
.
setter
@
value
.
setter
def
value
(
self
,
value
):
def
value
(
self
,
value
):
r
"""Bind a Tensor to this Node.
r
"""Bind a :class:`Tensor` to this Node."""
Args:
value: A :class:`Tensor`.
"""
if
isinstance
(
value
,
RawTensor
)
and
NodeMixin
.
get
(
value
,
None
)
is
not
None
:
if
isinstance
(
value
,
RawTensor
)
and
NodeMixin
.
get
(
value
,
None
)
is
not
None
:
setattr
(
value
,
"_NodeMixin__node"
,
None
)
setattr
(
value
,
"_NodeMixin__node"
,
None
)
self
.
_value
=
value
self
.
_value
=
value
...
...
imperative/python/megengine/traced_module/pytree.py
浏览文件 @
30095514
...
@@ -150,8 +150,8 @@ def tree_flatten(
...
@@ -150,8 +150,8 @@ def tree_flatten(
is_leaf
:
Callable
=
_is_leaf
,
is_leaf
:
Callable
=
_is_leaf
,
is_const_leaf
:
Callable
=
_is_const_leaf
,
is_const_leaf
:
Callable
=
_is_const_leaf
,
):
):
r
"""Flattens a
object into a list of values and a :cal
ss:`TreeDef` that can be used
r
"""Flattens a
pytree into a list of values and a :cla
ss:`TreeDef` that can be used
to reconstruct the
object
.
to reconstruct the
pytree
.
"""
"""
if
type
(
values
)
not
in
SUPPORTED_TYPE
:
if
type
(
values
)
not
in
SUPPORTED_TYPE
:
assert
is_leaf
(
values
),
values
assert
is_leaf
(
values
),
values
...
@@ -188,7 +188,7 @@ class TreeDef:
...
@@ -188,7 +188,7 @@ class TreeDef:
self
.
num_leaves
=
sum
(
ch
.
num_leaves
for
ch
in
children_defs
)
self
.
num_leaves
=
sum
(
ch
.
num_leaves
for
ch
in
children_defs
)
def
unflatten
(
self
,
leaves
):
def
unflatten
(
self
,
leaves
):
r
"""Given a list of values and a ``TreeDef``, builds a
object
.
r
"""Given a list of values and a ``TreeDef``, builds a
pytree
.
This is the inverse operation of ``tree_flatten``.
This is the inverse operation of ``tree_flatten``.
"""
"""
assert
len
(
leaves
)
==
self
.
num_leaves
assert
len
(
leaves
)
==
self
.
num_leaves
...
...
imperative/python/megengine/traced_module/traced_module.py
浏览文件 @
30095514
...
@@ -453,7 +453,7 @@ class InternalGraph:
...
@@ -453,7 +453,7 @@ class InternalGraph:
r
"""Get the list of output Nodes of this graph.
r
"""Get the list of output Nodes of this graph.
Returns:
Returns:
A list of
Node
.
A list of
``Node``
.
"""
"""
return
self
.
_outputs
return
self
.
_outputs
...
@@ -1937,7 +1937,7 @@ class TracedModule(Module):
...
@@ -1937,7 +1937,7 @@ class TracedModule(Module):
@
property
@
property
def
graph
(
self
)
->
InternalGraph
:
def
graph
(
self
)
->
InternalGraph
:
"""Return the ``InternalGraph`` of this ``TracedModule``
"""Return the ``InternalGraph`` of this ``TracedModule``
.
"""
"""
if
self
.
_is_top
:
if
self
.
_is_top
:
self
.
_update_ref
()
self
.
_update_ref
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录