Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
tensorflow
提交
0b2d2319
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,发现更多精彩内容 >>
提交
0b2d2319
编写于
3月 17, 2017
作者:
A
A. Unique TensorFlower
提交者:
TensorFlower Gardener
3月 17, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XLA] Add test for broadcast of a scalar provided as a parameter.
Change: 150490700
上级
815c7a76
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
34 addition
and
0 deletion
+34
-0
tensorflow/compiler/xla/tests/broadcast_simple_test.cc
tensorflow/compiler/xla/tests/broadcast_simple_test.cc
+13
-0
tensorflow/compiler/xla/tests/client_library_test_base.h
tensorflow/compiler/xla/tests/client_library_test_base.h
+21
-0
未找到文件。
tensorflow/compiler/xla/tests/broadcast_simple_test.cc
浏览文件 @
0b2d2319
...
...
@@ -48,6 +48,19 @@ XLA_TEST_F(BroadcastSimpleTest, ScalarTo2D_2x3) {
ComputeAndCompareR2
<
float
>
(
&
b
,
expected
,
{},
ErrorSpec
(
0.0001
));
}
XLA_TEST_F
(
BroadcastSimpleTest
,
ScalarParamTo2D_2x3
)
{
ComputationBuilder
b
(
client_
,
TestName
());
ComputationDataHandle
src
;
std
::
unique_ptr
<
GlobalData
>
param_data
=
CreateR0Parameter
<
float
>
(
2.25
f
,
/*parameter_number=*/
0
,
/*name=*/
"src"
,
/*builder=*/
&
b
,
/*data_handle=*/
&
src
);
b
.
Broadcast
(
src
,
{
2
,
3
});
Array2D
<
float
>
expected
(
2
,
3
,
2.25
);
ComputeAndCompareR2
<
float
>
(
&
b
,
expected
,
{
param_data
.
get
()},
ErrorSpec
(
0.0001
));
}
XLA_TEST_F
(
BroadcastSimpleTest
,
ScalarTo2D_2x0
)
{
ComputationBuilder
b
(
client_
,
TestName
());
b
.
Broadcast
(
b
.
ConstantR0
<
float
>
(
2.25
),
{
2
,
0
});
...
...
tensorflow/compiler/xla/tests/client_library_test_base.h
浏览文件 @
0b2d2319
...
...
@@ -216,6 +216,16 @@ class ClientLibraryTestBase : public ::testing::Test {
const
int
rows
,
const
int
cols
,
const
int
rows_padded
,
const
int
cols_padded
);
// Create a parameter instruction that wraps a given value and then stores
// into "data_handle" the global handle for that parameter.
//
// "parameter_number" is the parameter number.
// "name" is the name of the parameter instruction.
template
<
typename
NativeT
>
std
::
unique_ptr
<
GlobalData
>
CreateR0Parameter
(
NativeT
value
,
int64
parameter_number
,
const
string
&
name
,
ComputationBuilder
*
builder
,
ComputationDataHandle
*
data_handle
);
// Create a parameter instruction that wraps the given values and then stores
// into "data_handle" the global handle for that parameter.
//
...
...
@@ -370,6 +380,17 @@ void ClientLibraryTestBase::ComputeAndCompareR4(
arguments
,
error
);
}
template
<
typename
NativeT
>
std
::
unique_ptr
<
GlobalData
>
ClientLibraryTestBase
::
CreateR0Parameter
(
NativeT
value
,
int64
parameter_number
,
const
string
&
name
,
ComputationBuilder
*
builder
,
ComputationDataHandle
*
data_handle
)
{
std
::
unique_ptr
<
Literal
>
literal
=
LiteralUtil
::
CreateR0
(
value
);
std
::
unique_ptr
<
GlobalData
>
data
=
client_
->
TransferToServer
(
*
literal
).
ConsumeValueOrDie
();
*
data_handle
=
builder
->
Parameter
(
parameter_number
,
literal
->
shape
(),
name
);
return
data
;
}
template
<
typename
NativeT
>
std
::
unique_ptr
<
GlobalData
>
ClientLibraryTestBase
::
CreateR1Parameter
(
tensorflow
::
gtl
::
ArraySlice
<
NativeT
>
values
,
int64
parameter_number
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录