Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
ac3408bf
MegEngine
项目概览
MegEngine 天元
/
MegEngine
大约 1 年 前同步成功
通知
396
Star
4704
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,发现更多精彩内容 >>
提交
ac3408bf
编写于
9月 01, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(mge): add VarNode.value
GitOrigin-RevId: 1dc0d0c711b3bc3e7bfb04fa933839928d579a8c
上级
0537cb74
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
1 deletion
+18
-1
imperative/python/megengine/core/tensor/megbrain_graph.py
imperative/python/megengine/core/tensor/megbrain_graph.py
+4
-0
imperative/python/megengine/jit/tracing.py
imperative/python/megengine/jit/tracing.py
+1
-1
imperative/python/src/graph_rt.cpp
imperative/python/src/graph_rt.cpp
+13
-0
未找到文件。
imperative/python/megengine/core/tensor/megbrain_graph.py
浏览文件 @
ac3408bf
...
@@ -95,6 +95,10 @@ class VarNode(TensorBase):
...
@@ -95,6 +95,10 @@ class VarNode(TensorBase):
def
shape
(
self
):
def
shape
(
self
):
return
self
.
_node
.
shape
return
self
.
_node
.
shape
@
property
def
value
(
self
):
return
self
.
_node
.
value
class
OpNode
:
class
OpNode
:
def
__init__
(
self
,
node
:
_imperative_rt
.
OperatorNode
):
def
__init__
(
self
,
node
:
_imperative_rt
.
OperatorNode
):
...
...
imperative/python/megengine/jit/tracing.py
浏览文件 @
ac3408bf
...
@@ -399,7 +399,7 @@ class LazyEvalTensor(RawTensor):
...
@@ -399,7 +399,7 @@ class LazyEvalTensor(RawTensor):
return
self
.
__varnode
.
shape
return
self
.
__varnode
.
shape
def
numpy
(
self
):
def
numpy
(
self
):
r
aise
RuntimeError
(
"cannot read value during symbolic tracing"
)
r
eturn
self
.
__varnode
.
value
def
_dev_tensor
(
self
):
def
_dev_tensor
(
self
):
raise
RuntimeError
(
"cannot access data during symbolic tracing"
)
raise
RuntimeError
(
"cannot access data during symbolic tracing"
)
...
...
imperative/python/src/graph_rt.cpp
浏览文件 @
ac3408bf
...
@@ -58,6 +58,19 @@ void init_graph_rt(py::module m) {
...
@@ -58,6 +58,19 @@ void init_graph_rt(py::module m) {
return
nullptr
;
return
nullptr
;
}
}
return
mgr
.
infer_shape_fallible
(
v
);
return
mgr
.
infer_shape_fallible
(
v
);
})
.
def_property_readonly
(
"value"
,
[](
cg
::
VarNode
*
v
)
->
py
::
object
{
auto
&&
mgr
=
v
->
owner_graph
()
->
static_infer_manager
();
auto
&&
type
=
mgr
.
get_infer_type
(
v
);
using
InferType
=
cg
::
static_infer
::
InferType
;
if
(
!
(
type
.
value
&
(
InferType
::
CONST
|
InferType
::
RT_STATIC
)))
{
return
py
::
none
();
}
auto
*
val
=
mgr
.
infer_value_fallible
(
v
);
if
(
!
val
)
{
return
py
::
none
();
}
return
py
::
cast
(
*
val
).
attr
(
"numpy"
)();
});
});
py
::
class_
<
cg
::
OperatorNodeBase
,
GraphNodePtr
<
cg
::
OperatorNodeBase
>>
(
m
,
"OperatorNode"
)
py
::
class_
<
cg
::
OperatorNodeBase
,
GraphNodePtr
<
cg
::
OperatorNodeBase
>>
(
m
,
"OperatorNode"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录