Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
tensorflow
提交
21a1d476
T
tensorflow
项目概览
xxadev
/
tensorflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tensorflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
21a1d476
编写于
7月 11, 2019
作者:
P
Peter Hawkins
提交者:
TensorFlower Gardener
7月 11, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XLA:Python] Inline TransferLiteralToHostAsync into its only caller. No functional changes.
PiperOrigin-RevId: 257660458
上级
844aa275
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
33 deletion
+23
-33
tensorflow/compiler/xla/python/local_client.cc
tensorflow/compiler/xla/python/local_client.cc
+23
-33
未找到文件。
tensorflow/compiler/xla/python/local_client.cc
浏览文件 @
21a1d476
...
...
@@ -224,9 +224,27 @@ StatusOr<pybind11::object> PyLocalClient::TransferFromOutfeed(
return
LiteralToPython
(
std
::
make_shared
<
Literal
>
(
std
::
move
(
literal
)));
}
static
StatusOr
<
std
::
unique_ptr
<
PyLocalBuffer
>>
TransferHostToDeviceAsync
(
const
PythonBufferTree
&
tree
,
int
device_ordinal
,
std
::
shared_ptr
<
PyLocalClient
>
client
,
Device
*
device
)
{
/* static */
StatusOr
<
std
::
unique_ptr
<
PyLocalBuffer
>>
PyLocalBuffer
::
FromPython
(
const
py
::
object
&
argument
,
std
::
shared_ptr
<
PyLocalClient
>
client
,
int
device_ordinal
)
{
tensorflow
::
profiler
::
TraceMe
traceme
(
"PyLocalBuffer::FromPython"
);
TF_ASSIGN_OR_RETURN
(
PythonBufferTree
tree
,
GetPythonBufferTree
(
argument
));
client
->
py_ref_manager
().
CollectGarbage
();
// Take a reference to the buffer to ensure that the inputs in host memory
// remain live until the transfer is complete.
auto
py_buffer_ref
=
client
->
py_ref_manager
().
ManageReferences
(
absl
::
MakeSpan
(
tree
.
arrays
));
tree
.
arrays
.
clear
();
// We are done manipulating Python objects; release the GIL.
py
::
gil_scoped_release
gil_release
;
VLOG
(
1
)
<<
"PyLocalBuffer::FromPython: shape: "
<<
tree
.
shape
.
ToString
()
<<
" device ordinal: "
<<
device_ordinal
;
Device
*
device
=
&
client
->
device
(
device_ordinal
);
se
::
DeviceMemoryAllocator
*
allocator
=
client
->
allocator
();
TransferManager
*
transfer_manager
=
client
->
client
()
->
backend
().
transfer_manager
();
...
...
@@ -269,38 +287,10 @@ static StatusOr<std::unique_ptr<PyLocalBuffer>> TransferHostToDeviceAsync(
if
(
device
->
synchronous_deallocation
())
{
device
->
ThenRelease
(
device
->
host_to_device_stream
(),
device_buffer
);
}
return
absl
::
make_unique
<
PyLocalBuffer
>
(
shape
,
std
::
move
(
device_buffer
),
std
::
move
(
client
));
}
/* static */
StatusOr
<
std
::
unique_ptr
<
PyLocalBuffer
>>
PyLocalBuffer
::
FromPython
(
const
py
::
object
&
argument
,
std
::
shared_ptr
<
PyLocalClient
>
client
,
int
device_ordinal
)
{
tensorflow
::
profiler
::
TraceMe
traceme
(
"PyLocalBuffer::FromPython"
);
TF_ASSIGN_OR_RETURN
(
PythonBufferTree
tree
,
GetPythonBufferTree
(
argument
));
client
->
py_ref_manager
().
CollectGarbage
();
// Take a reference to the buffer to ensure that the inputs in host memory
// remain live until the transfer is complete.
auto
py_buffer_ref
=
client
->
py_ref_manager
().
ManageReferences
(
absl
::
MakeSpan
(
tree
.
arrays
));
tree
.
arrays
.
clear
();
// We are done manipulating Python objects; release the GIL.
py
::
gil_scoped_release
gil_release
;
VLOG
(
1
)
<<
"PyLocalBuffer::FromPython: shape: "
<<
tree
.
shape
.
ToString
()
<<
" device ordinal: "
<<
device_ordinal
;
Device
*
device
=
&
client
->
device
(
device_ordinal
);
TF_ASSIGN_OR_RETURN
(
std
::
unique_ptr
<
PyLocalBuffer
>
buffer
,
TransferHostToDeviceAsync
(
tree
,
device_ordinal
,
std
::
move
(
client
),
device
));
device
->
ThenRelease
(
device
->
host_to_device_stream
(),
std
::
move
(
py_buffer_ref
));
return
buffer
;
return
absl
::
make_unique
<
PyLocalBuffer
>
(
shape
,
std
::
move
(
device_buffer
),
std
::
move
(
client
));
}
/* static */
StatusOr
<
std
::
unique_ptr
<
PyLocalBuffer
>>
PyLocalBuffer
::
MakeTuple
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录