Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
48db45d1
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看板
提交
48db45d1
编写于
8月 02, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf(interpreter): try put device value with host to reduce d2h
GitOrigin-RevId: 63d36e770609f7666e823beca579d53d90b4e6b0
上级
a605f38b
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
7 addition
and
8 deletion
+7
-8
imperative/python/src/tensor.cpp
imperative/python/src/tensor.cpp
+3
-4
imperative/src/impl/interpreter/interpreter_impl.cpp
imperative/src/impl/interpreter/interpreter_impl.cpp
+2
-2
imperative/src/impl/interpreter/interpreter_impl.h
imperative/src/impl/interpreter/interpreter_impl.h
+1
-1
imperative/src/include/megbrain/imperative/interpreter.h
imperative/src/include/megbrain/imperative/interpreter.h
+1
-1
未找到文件。
imperative/python/src/tensor.cpp
浏览文件 @
48db45d1
...
...
@@ -44,7 +44,7 @@ PyObject *cpp_apply_backward_varnode;
std
::
shared_ptr
<
Tensor
>
make_const
(
imperative
::
TensorPtr
value
)
{
if
(
!
(
ApplyContext
::
global_enable
&
Tensor
::
Flags
::
TRACE
))
{
return
std
::
make_shared
<
Tensor
>
(
interpreter_for_py
->
put
(
value
->
dev_tensor
()));
return
std
::
make_shared
<
Tensor
>
(
interpreter_for_py
->
put
(
value
->
dev_tensor
()
,
value
->
get_value
()
));
}
py
::
tuple
tup
(
6
);
auto
data
=
value
->
get_value
();
...
...
@@ -248,7 +248,7 @@ TensorWrapper::TensorWrapper(PyObject* args, PyObject* kwargs) {
// for DeviceTensorND
if
(
strstr
(
arg0
->
ob_type
->
tp_name
,
"DeviceTensorND"
))
{
auto
dv
=
py
::
handle
(
arg0
).
cast
<
DeviceTensorND
>
();
interpreter
::
Interpreter
::
Handle
handle
=
interpreter_for_py
->
put
(
dv
);
interpreter
::
Interpreter
::
Handle
handle
=
interpreter_for_py
->
put
(
dv
,
{}
);
m_tensor
=
std
::
make_shared
<
Tensor
>
(
handle
);
}
else
{
throw
py
::
type_error
(
"single argument is not tensor, varnode or devicetensor"
);
...
...
@@ -347,7 +347,6 @@ SET_GET_NAME(user_custom_name)
SET_GET_NAME
(
automatic_name
)
#undef SET_GET_NAME
PyObject
*
TensorWrapper
::
handle
()
{
return
py
::
cast
(
m_tensor
->
m_handle
).
release
().
ptr
();
}
...
...
@@ -532,7 +531,7 @@ PyObject* TensorWrapper::_dev_tensor(){
// set m_handle to make it a real tensor
auto
py_dev_tensor
=
py
::
reinterpret_borrow
<
py
::
object
>
(
dev_tensor
);
auto
sh
=
interpreter_for_py
->
put
(
py_dev_tensor
.
cast
<
DeviceTensorND
>
());
auto
sh
=
interpreter_for_py
->
put
(
py_dev_tensor
.
cast
<
DeviceTensorND
>
()
,
{}
);
m_tensor
->
m_handle
=
std
::
move
(
SharedHandle
(
sh
));
// compiled info is useless after m_handle is set
...
...
imperative/src/impl/interpreter/interpreter_impl.cpp
浏览文件 @
48db45d1
...
...
@@ -135,7 +135,7 @@ TensorInfo* ChannelImpl::put_impl(const HostTensorND& value, bool no_cache) {
return
info
;
}
Handle
ChannelImpl
::
put
(
const
DeviceTensorND
&
data
)
{
Handle
ChannelImpl
::
put
(
const
DeviceTensorND
&
data
,
const
HostTensorND
&
hvalue
)
{
MGB_LOCK_GUARD
(
m_spin
);
auto
&
state
=
get_channel_state
();
mgb_assert
(
check_available
(),
"Channel already closed"
);
...
...
@@ -144,7 +144,7 @@ Handle ChannelImpl::put(const DeviceTensorND& data) {
RECORD_EVENT
(
TensorCommandEvent
,
info
->
id
,
TensorCommandEvent
::
Put
);
init
(
info
,
{
data
.
layout
(),
data
.
comp_node
()});
info
->
mem_desc
.
id
=
StorageIdentifier
::
make
(
++
m_storage_id
);
info
->
ptr
=
Tensor
::
make
(
data
);
info
->
ptr
=
Tensor
::
make
(
data
,
hvalue
);
RECORD_EVENT
(
TensorProduceEvent
,
info
->
id
,
info
->
desc
.
layout
,
info
->
desc
.
comp_node
,
data
.
raw_ptr
());
info
->
status
=
TensorInfo
::
Produced
;
RECORD_EVENT
(
TensorCommandFinishEvent
,
info
->
id
,
TensorCommandFinishEvent
::
Put
);
...
...
imperative/src/impl/interpreter/interpreter_impl.h
浏览文件 @
48db45d1
...
...
@@ -42,7 +42,7 @@ struct ChannelImpl : Interpreter::Channel {
~
ChannelImpl
()
override
;
Handle
put
(
const
HostTensorND
&
value
,
bool
no_cache
)
override
;
Handle
put
(
const
DeviceTensorND
&
value
)
override
;
Handle
put
(
const
DeviceTensorND
&
value
,
const
HostTensorND
&
hvalue
)
override
;
void
del
(
Handle
)
override
;
void
swap_in
(
Handle
)
override
;
...
...
imperative/src/include/megbrain/imperative/interpreter.h
浏览文件 @
48db45d1
...
...
@@ -23,7 +23,7 @@ struct Interpreter {
virtual
~
Channel
()
=
default
;
virtual
Handle
put
(
const
HostTensorND
&
value
,
bool
no_cache
)
=
0
;
virtual
Handle
put
(
const
DeviceTensorND
&
value
)
=
0
;
virtual
Handle
put
(
const
DeviceTensorND
&
value
,
const
HostTensorND
&
hvalue
)
=
0
;
virtual
void
del
(
Handle
)
=
0
;
virtual
void
swap_in
(
Handle
)
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录