Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8681c580
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8681c580
编写于
7月 12, 2017
作者:
F
fengjiayi
提交者:
GitHub
7月 12, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2813 from Canpio/dev_update_dim
Remove Dim::contiguous and Dim::contiguous_strides
上级
76b4dd62
2dbe60e4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
0 addition
and
76 deletion
+0
-76
paddle/framework/dim.h
paddle/framework/dim.h
+0
-48
paddle/framework/dim_test.cu
paddle/framework/dim_test.cu
+0
-28
未找到文件。
paddle/framework/dim.h
浏览文件 @
8681c580
...
...
@@ -266,29 +266,6 @@ HOSTDEVICE inline bool contained(const Dim<1>& idx, const Dim<1>& size) {
return
((
0
<=
idx
.
head
)
&&
(
idx
.
head
<
size
.
head
));
}
/**
* \brief Check if a size and a stride create a Fortran order contiguous
* block of memory.
*/
template
<
int
i
>
HOST
bool
contiguous
(
const
Dim
<
i
>&
size
,
const
Dim
<
i
>&
stride
,
int
mul
=
1
)
{
if
(
product
(
size
)
==
0
)
return
true
;
int
contiguous_stride
=
get
<
0
>
(
size
)
==
1
?
0
:
mul
;
return
(
get
<
0
>
(
stride
)
==
contiguous_stride
&&
contiguous
(
size
.
tail
,
stride
.
tail
,
mul
*
get
<
0
>
(
size
)));
}
///\cond HIDDEN
// Base case of contiguous, check the nth stride is the size of
// the prefix multiply of n-1 dims.
template
<
>
inline
bool
contiguous
(
const
Dim
<
1
>&
size
,
const
Dim
<
1
>&
stride
,
int
mul
)
{
if
(
get
<
0
>
(
size
)
==
0
)
return
true
;
int
contiguous_stride
=
get
<
0
>
(
size
)
==
1
?
0
:
mul
;
return
get
<
0
>
(
stride
)
==
contiguous_stride
;
}
///\endcond
/**
* \brief Compute exclusive prefix-multiply of a Dim.
*/
...
...
@@ -306,31 +283,6 @@ HOSTDEVICE inline Dim<1> ex_prefix_mul(const Dim<1>& src, int mul) {
}
///\endcond
/**
* \brief Calculate strides of a contiguous array of the given size
*
* Sets the stride for any dimension with an extent of 1 to 0.
* \param size Dim object containing the size of the array.
* \param base The base stride to use.
* \return Dim object the same size as \p size with the strides.
*/
template
<
int
i
>
HOSTDEVICE
Dim
<
i
>
contiguous_strides
(
const
Dim
<
i
>&
size
,
int
base
=
1
)
{
int
stride
=
size
.
head
==
1
?
0
:
base
;
return
Dim
<
i
>
(
stride
,
contiguous_strides
(
size
.
tail
,
base
*
size
.
head
));
}
///\cond HIDDEN
// Base case of contiguous_strides
template
<
>
HOSTDEVICE
inline
Dim
<
1
>
contiguous_strides
(
const
Dim
<
1
>&
size
,
int
base
)
{
int
stride
=
size
.
head
==
1
?
0
:
base
;
return
Dim
<
1
>
(
stride
);
}
///\endcond
/**
* Add two dimensions together
*/
...
...
paddle/framework/dim_test.cu
浏览文件 @
8681c580
...
...
@@ -58,24 +58,6 @@ TEST(Dim, Equality) {
EXPECT_EQ
(
paddle
::
framework
::
get
<
1
>
(
c
),
3
);
EXPECT_EQ
(
paddle
::
framework
::
get
<
2
>
(
c
),
12
);
// contiguous_strides
c
=
paddle
::
framework
::
contiguous_strides
(
paddle
::
framework
::
Dim
<
3
>
(
10
,
1
,
10
));
EXPECT_EQ
(
paddle
::
framework
::
get
<
0
>
(
c
),
1
);
EXPECT_EQ
(
paddle
::
framework
::
get
<
1
>
(
c
),
0
);
EXPECT_EQ
(
paddle
::
framework
::
get
<
2
>
(
c
),
10
);
c
=
paddle
::
framework
::
contiguous_strides
(
paddle
::
framework
::
Dim
<
3
>
(
10
,
10
,
1
));
EXPECT_EQ
(
paddle
::
framework
::
get
<
0
>
(
c
),
1
);
EXPECT_EQ
(
paddle
::
framework
::
get
<
1
>
(
c
),
10
);
EXPECT_EQ
(
paddle
::
framework
::
get
<
2
>
(
c
),
0
);
c
=
paddle
::
framework
::
contiguous_strides
(
paddle
::
framework
::
Dim
<
3
>
(
1
,
10
,
10
));
EXPECT_EQ
(
paddle
::
framework
::
get
<
0
>
(
c
),
0
);
EXPECT_EQ
(
paddle
::
framework
::
get
<
1
>
(
c
),
1
);
EXPECT_EQ
(
paddle
::
framework
::
get
<
2
>
(
c
),
10
);
c
=
paddle
::
framework
::
contiguous_strides
(
paddle
::
framework
::
Dim
<
3
>
(
2
,
3
,
4
));
EXPECT_EQ
(
paddle
::
framework
::
get
<
0
>
(
c
),
1
);
EXPECT_EQ
(
paddle
::
framework
::
get
<
1
>
(
c
),
2
);
EXPECT_EQ
(
paddle
::
framework
::
get
<
2
>
(
c
),
6
);
// generate from an index
auto
size
=
paddle
::
framework
::
make_dim
(
4
,
5
,
2
);
c
=
paddle
::
framework
::
Dim
<
3
>
(
14
,
size
);
...
...
@@ -101,16 +83,6 @@ TEST(Dim, Bool) {
EXPECT_TRUE
(
a
==
a
);
EXPECT_FALSE
(
a
==
b
);
EXPECT_TRUE
(
a
==
c
);
// contiguous check
int
x
=
4
,
y
=
5
,
z
=
2
;
paddle
::
framework
::
Dim
<
3
>
sizef
(
x
,
y
,
z
);
paddle
::
framework
::
Dim
<
3
>
stridea
(
1
,
x
,
x
*
y
);
paddle
::
framework
::
Dim
<
3
>
strideb
(
2
,
2
*
x
,
2
*
x
*
y
);
paddle
::
framework
::
Dim
<
3
>
stridec
(
1
,
x
,
2
*
x
*
y
);
EXPECT_TRUE
(
paddle
::
framework
::
contiguous
(
sizef
,
stridea
));
EXPECT_FALSE
(
paddle
::
framework
::
contiguous
(
sizef
,
strideb
));
EXPECT_FALSE
(
paddle
::
framework
::
contiguous
(
sizef
,
stridec
));
}
TEST
(
Dim
,
Print
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录