Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
tensorflow
提交
0a374c71
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,发现更多精彩内容 >>
提交
0a374c71
编写于
3月 14, 2017
作者:
A
A. Unique TensorFlower
提交者:
TensorFlower Gardener
3月 14, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add matmul large array tests.
Change: 150099362
上级
90bc9563
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
80 addition
and
0 deletion
+80
-0
tensorflow/compiler/xla/tests/dot_operation_test.cc
tensorflow/compiler/xla/tests/dot_operation_test.cc
+80
-0
未找到文件。
tensorflow/compiler/xla/tests/dot_operation_test.cc
浏览文件 @
0a374c71
...
@@ -54,6 +54,8 @@ class DotOperationTest : public ClientLibraryTestBase {
...
@@ -54,6 +54,8 @@ class DotOperationTest : public ClientLibraryTestBase {
template
<
typename
Element
>
template
<
typename
Element
>
void
TestNonsquareMatrixDot
(
bool
lhs_row_major
=
false
,
void
TestNonsquareMatrixDot
(
bool
lhs_row_major
=
false
,
bool
rhs_row_major
=
false
);
bool
rhs_row_major
=
false
);
void
TestMatrixDot
(
int
M
,
int
K
,
int
N
,
bool
lhs_row_major
=
false
,
bool
rhs_row_major
=
false
);
};
};
XLA_TEST_F
(
DotOperationTest
,
ZeroElementVectorDotF32
)
{
XLA_TEST_F
(
DotOperationTest
,
ZeroElementVectorDotF32
)
{
...
@@ -170,6 +172,84 @@ void DotOperationTest::TestSquareMatrixDot(bool lhs_row_major,
...
@@ -170,6 +172,84 @@ void DotOperationTest::TestSquareMatrixDot(bool lhs_row_major,
&
builder
,
expected
,
{
lhs_handle
.
get
(),
rhs_handle
.
get
()},
error_spec_
);
&
builder
,
expected
,
{
lhs_handle
.
get
(),
rhs_handle
.
get
()},
error_spec_
);
}
}
void
DotOperationTest
::
TestMatrixDot
(
int
M
,
int
K
,
int
N
,
bool
lhs_row_major
,
bool
rhs_row_major
)
{
std
::
unique_ptr
<
Array2D
<
float
>>
lhs_data
=
MakeLinspaceArray2D
(
0.0
,
1.0
,
M
,
K
);
std
::
unique_ptr
<
Literal
>
lhs_lit
=
LiteralUtil
::
CreateR2FromArray2DWithLayout
(
*
lhs_data
,
LayoutUtil
::
MakeLayout
(
MinorToMajorForIsRowMajor
(
lhs_row_major
)));
auto
lhs_handle
=
client_
->
TransferToServer
(
*
lhs_lit
).
ConsumeValueOrDie
();
std
::
unique_ptr
<
Array2D
<
float
>>
rhs_data
=
MakeLinspaceArray2D
(
0.0
,
1.0
,
K
,
N
);
std
::
unique_ptr
<
Literal
>
rhs_lit
=
LiteralUtil
::
CreateR2FromArray2DWithLayout
(
*
rhs_data
,
LayoutUtil
::
MakeLayout
(
MinorToMajorForIsRowMajor
(
rhs_row_major
)));
auto
rhs_handle
=
client_
->
TransferToServer
(
*
rhs_lit
).
ConsumeValueOrDie
();
ComputationBuilder
builder
(
client_
,
TestName
());
auto
prim_type
=
primitive_util
::
NativeToPrimitiveType
<
float
>
();
auto
result
=
builder
.
Dot
(
builder
.
Parameter
(
0
,
ShapeUtil
::
MakeShape
(
prim_type
,
{
M
,
K
}),
"lhs"
),
builder
.
Parameter
(
1
,
ShapeUtil
::
MakeShape
(
prim_type
,
{
K
,
N
}),
"rhs"
));
std
::
unique_ptr
<
Array2D
<
float
>>
expected
=
ReferenceUtil
::
MatmulArray2D
(
*
lhs_data
,
*
rhs_data
);
ComputeAndCompareR2
<
float
>
(
&
builder
,
*
expected
,
{
lhs_handle
.
get
(),
rhs_handle
.
get
()},
ErrorSpec
(
0.3
,
3e-3
));
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_12_117_7_MinorToMajorTF
)
{
TestMatrixDot
(
12
,
117
,
7
,
true
,
false
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_12_117_7_MinorToMajorFT
)
{
TestMatrixDot
(
12
,
117
,
7
,
false
,
true
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_12_117_7_MinorToMajorTT
)
{
TestMatrixDot
(
12
,
117
,
7
,
true
,
true
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_12_117_7_MinorToMajorFF
)
{
TestMatrixDot
(
12
,
117
,
7
,
false
,
false
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_270_270_520_MinorToMajorTT
)
{
TestMatrixDot
(
270
,
270
,
520
,
true
,
true
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_270_270_520_MinorToMajorTF
)
{
TestMatrixDot
(
270
,
270
,
520
,
true
,
false
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_270_270_520_MinorToMajorFT
)
{
TestMatrixDot
(
270
,
270
,
520
,
false
,
true
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_270_270_520_MinorToMajorFF
)
{
TestMatrixDot
(
270
,
270
,
520
,
false
,
false
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_260_3_520_MinorToMajorTT
)
{
TestMatrixDot
(
269
,
3
,
520
,
true
,
true
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_260_3_520_MinorToMajorTF
)
{
TestMatrixDot
(
260
,
3
,
520
,
true
,
false
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_260_3_520_MinorToMajorFT
)
{
TestMatrixDot
(
260
,
3
,
520
,
false
,
true
);
}
XLA_TEST_F
(
DotOperationTest
,
MatrixDotF32_260_3_520_MinorToMajorFF
)
{
TestMatrixDot
(
260
,
3
,
520
,
false
,
false
);
}
XLA_TEST_F
(
DotOperationTest
,
SquareMatrixDotF32MinorToMajorFF
)
{
XLA_TEST_F
(
DotOperationTest
,
SquareMatrixDotF32MinorToMajorFF
)
{
constexpr
bool
kLhsRowMajor
=
false
;
constexpr
bool
kLhsRowMajor
=
false
;
constexpr
bool
kRhsRowMajor
=
false
;
constexpr
bool
kRhsRowMajor
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录