Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
0cef33a4
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0cef33a4
编写于
7月 03, 2018
作者:
C
chenweihang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adjust the dims range to [1,6] and fix some problem
上级
9ca88fa8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
18 deletion
+16
-18
paddle/fluid/operators/squeeze_op.cc
paddle/fluid/operators/squeeze_op.cc
+3
-3
paddle/fluid/operators/squeeze_op.cu
paddle/fluid/operators/squeeze_op.cu
+0
-2
python/paddle/fluid/tests/unittests/test_squeeze_op.py
python/paddle/fluid/tests/unittests/test_squeeze_op.py
+13
-13
未找到文件。
paddle/fluid/operators/squeeze_op.cc
浏览文件 @
0cef33a4
...
...
@@ -33,10 +33,10 @@ class SqueezeOp : public framework::OperatorWithKernel {
"Output(Out) of SqueezeOp should not be null."
);
const
auto
&
x_dims
=
ctx
->
GetInputDim
(
"X"
);
// Check input tensor dims (<
9)
.
PADDLE_ENFORCE
(
x_dims
.
size
()
<=
9
,
// Check input tensor dims (<
6) Eigen limit
.
PADDLE_ENFORCE
(
x_dims
.
size
()
<=
6
,
"Invalid dimnesions, dynamic dimensions must have "
"between [1,
9] dimensions
."
);
"between [1,
6] dimensions (Eigen limit)
."
);
const
auto
&
axes
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"axes"
);
for
(
int
a
:
axes
)
{
...
...
paddle/fluid/operators/squeeze_op.cu
浏览文件 @
0cef33a4
...
...
@@ -12,8 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#define EIGEN_USE_GPU
#include "paddle/fluid/operators/squeeze_op.h"
namespace
ops
=
paddle
::
operators
;
...
...
python/paddle/fluid/tests/unittests/test_squeeze_op.py
浏览文件 @
0cef33a4
...
...
@@ -27,7 +27,7 @@ class TestSqueezeOp1(OpTest):
self
.
op_type
=
"squeeze"
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
ori_shape
).
astype
(
"float32"
)}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
al
ce"
:
False
}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
la
ce"
:
False
}
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
new_shape
)}
def
test_check_output
(
self
):
...
...
@@ -46,7 +46,7 @@ class TestSqueezeOp2(OpTest):
self
.
op_type
=
"squeeze"
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
ori_shape
).
astype
(
"float32"
)}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
al
ce"
:
False
}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
la
ce"
:
False
}
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
new_shape
)}
def
test_check_output
(
self
):
...
...
@@ -65,7 +65,7 @@ class TestSqueezeOp3(OpTest):
self
.
op_type
=
"squeeze"
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
ori_shape
).
astype
(
"float32"
)}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
al
ce"
:
False
}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
la
ce"
:
False
}
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
new_shape
)}
def
test_check_output
(
self
):
...
...
@@ -78,13 +78,13 @@ class TestSqueezeOp3(OpTest):
# Correct: Just part of axes be squeezed.
class
TestSqueezeOp4
(
OpTest
):
def
setUp
(
self
):
ori_shape
=
(
1
,
3
,
1
,
5
,
1
,
4
,
1
)
axes
=
(
2
,
6
)
new_shape
=
(
1
,
3
,
5
,
1
,
4
)
ori_shape
=
(
3
,
1
,
5
,
1
,
4
,
1
)
axes
=
(
1
,
-
1
)
new_shape
=
(
3
,
5
,
1
,
4
)
self
.
op_type
=
"squeeze"
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
ori_shape
).
astype
(
"float32"
)}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
al
ce"
:
False
}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
la
ce"
:
False
}
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
new_shape
)}
def
test_check_output
(
self
):
...
...
@@ -122,7 +122,7 @@ class TestSqueezeOpInplace2(OpTest):
self
.
op_type
=
"squeeze"
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
ori_shape
).
astype
(
"float32"
)}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
al
ce"
:
True
}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
la
ce"
:
True
}
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
new_shape
)}
def
test_check_output
(
self
):
...
...
@@ -141,7 +141,7 @@ class TestSqueezeOpInplace3(OpTest):
self
.
op_type
=
"squeeze"
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
ori_shape
).
astype
(
"float32"
)}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
al
ce"
:
True
}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
la
ce"
:
True
}
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
new_shape
)}
def
test_check_output
(
self
):
...
...
@@ -154,13 +154,13 @@ class TestSqueezeOpInplace3(OpTest):
# Correct: Inpalce. Just part of axes be squeezed.
class
TestSqueezeOpInplace4
(
OpTest
):
def
setUp
(
self
):
ori_shape
=
(
1
,
3
,
1
,
5
,
1
,
4
,
1
)
axes
=
(
2
,
6
)
new_shape
=
(
1
,
3
,
5
,
1
,
4
)
ori_shape
=
(
3
,
1
,
5
,
1
,
4
,
1
)
axes
=
(
1
,
-
1
)
new_shape
=
(
3
,
5
,
1
,
4
)
self
.
op_type
=
"squeeze"
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
ori_shape
).
astype
(
"float32"
)}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
al
ce"
:
True
}
self
.
attrs
=
{
"axes"
:
axes
,
"inp
la
ce"
:
True
}
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
new_shape
)}
def
test_check_output
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录