Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
tensorflow
提交
6ba02f0e
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,体验更适合开发者的 AI 搜索 >>
提交
6ba02f0e
编写于
7月 31, 2017
作者:
A
Artem Belevich
提交者:
TensorFlower Gardener
7月 31, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XLA] Added HasAllocationAt() helper function.
PiperOrigin-RevId: 163742985
上级
18304683
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
3 deletion
+41
-3
tensorflow/compiler/xla/service/buffer_assignment.cc
tensorflow/compiler/xla/service/buffer_assignment.cc
+8
-3
tensorflow/compiler/xla/service/buffer_assignment.h
tensorflow/compiler/xla/service/buffer_assignment.h
+5
-0
tensorflow/compiler/xla/service/buffer_assignment_test.cc
tensorflow/compiler/xla/service/buffer_assignment_test.cc
+28
-0
未找到文件。
tensorflow/compiler/xla/service/buffer_assignment.cc
浏览文件 @
6ba02f0e
...
...
@@ -200,10 +200,10 @@ BufferAllocation* BufferAssignment::GetMutableAllocation(
return
const_cast
<
BufferAllocation
*>
(
&
GetAllocation
(
index
));
}
bool
BufferAssignment
::
Has
TopLevelAllocation
(
const
HloInstruction
*
instruction
)
const
{
bool
BufferAssignment
::
Has
AllocationAt
(
const
HloInstruction
*
instruction
,
const
ShapeIndex
&
index
)
const
{
for
(
const
LogicalBuffer
*
buffer
:
GetPointsToSet
(
instruction
).
element
(
/*index=*/
{}
))
{
GetPointsToSet
(
instruction
).
element
(
index
))
{
if
(
allocation_index_for_buffer_
.
count
(
buffer
)
>
0
)
{
return
true
;
}
...
...
@@ -211,6 +211,11 @@ bool BufferAssignment::HasTopLevelAllocation(
return
false
;
}
bool
BufferAssignment
::
HasTopLevelAllocation
(
const
HloInstruction
*
instruction
)
const
{
return
HasAllocationAt
(
instruction
,
/*index=*/
{});
}
StatusOr
<
BufferAllocation
::
Slice
>
BufferAssignment
::
GetUniqueSlice
(
const
HloInstruction
*
instruction
,
const
ShapeIndex
&
index
)
const
{
VLOG
(
3
)
<<
"Trying to find unique slice for "
<<
instruction
->
name
()
<<
" ["
...
...
tensorflow/compiler/xla/service/buffer_assignment.h
浏览文件 @
6ba02f0e
...
...
@@ -281,6 +281,11 @@ class BufferAssignment {
std
::
set
<
BufferAllocation
::
Slice
>
GetAllSlices
(
const
HloInstruction
*
instruction
,
const
ShapeIndex
&
index
)
const
;
// Convenience function which returns whether the buffer of the
// instruction at the given index is assigned an allocation.
bool
HasAllocationAt
(
const
HloInstruction
*
instruction
,
const
ShapeIndex
&
index
)
const
;
// Convenience function which returns whether the top-level buffer of the
// instruction (index == {}) is assigned an allocation.
bool
HasTopLevelAllocation
(
const
HloInstruction
*
instruction
)
const
;
...
...
tensorflow/compiler/xla/service/buffer_assignment_test.cc
浏览文件 @
6ba02f0e
...
...
@@ -296,6 +296,34 @@ TEST_F(BufferAssignmentTest, BufferForConst) {
GetAssignedOutputAllocation
(
*
buffers
,
add
);
}
TEST_F
(
BufferAssignmentTest
,
HasAllocationAt
)
{
// Create a tuple with non-const and const elements and check that
// HasAllocationAt works correctly.
auto
builder
=
HloComputation
::
Builder
(
TestName
());
auto
param0
=
builder
.
AddInstruction
(
HloInstruction
::
CreateParameter
(
0
,
f32vec100_
,
"param0"
));
auto
constant
=
builder
.
AddInstruction
(
HloInstruction
::
CreateConstant
(
Literal
::
CreateR0
<
int
>
(
1
)));
auto
negate
=
builder
.
AddInstruction
(
HloInstruction
::
CreateUnary
(
f32vec100_
,
HloOpcode
::
kNegate
,
param0
));
auto
tuple
=
builder
.
AddInstruction
(
HloInstruction
::
CreateTuple
({
negate
,
param0
,
constant
}));
auto
module
=
CreateNewModule
();
module
->
AddEntryComputation
(
builder
.
Build
());
auto
buffers
=
RunBufferAssignment
(
module
.
get
());
// Make sure that HasAllocationAt() agrees with what HasTopLevelAllocation()
// reports for the instruction directly.
EXPECT_EQ
(
buffers
->
HasTopLevelAllocation
(
tuple
),
buffers
->
HasAllocationAt
(
tuple
,
/*index=*/
{}));
EXPECT_EQ
(
buffers
->
HasTopLevelAllocation
(
negate
),
buffers
->
HasAllocationAt
(
tuple
,
/*index=*/
{
0
}));
EXPECT_EQ
(
buffers
->
HasTopLevelAllocation
(
param0
),
buffers
->
HasAllocationAt
(
tuple
,
/*index=*/
{
1
}));
EXPECT_EQ
(
buffers
->
HasTopLevelAllocation
(
constant
),
buffers
->
HasAllocationAt
(
tuple
,
/*index=*/
{
2
}));
}
TEST_F
(
BufferAssignmentTest
,
BufferForOutputConst
)
{
// This computation copies a constant to output.
auto
builder
=
HloComputation
::
Builder
(
TestName
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录