Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pool op #4146

Merged
merged 25 commits into from
Sep 30, 2017
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9e7c0b5
Add pooling2d(max, ave) and pooling3d(max, ave) functor
chengduoZH Sep 20, 2017
a847738
Add pooling2d(max, ave) and pooling3d(max, ave) Op
chengduoZH Sep 20, 2017
33d9999
Add pool2d unit test
chengduoZH Sep 21, 2017
510f008
Add pool3d unit test
chengduoZH Sep 21, 2017
3416f5e
fix function define
chengduoZH Sep 21, 2017
50b8ec0
fix unit test
chengduoZH Sep 21, 2017
84a2512
fix parameter name and function define
chengduoZH Sep 22, 2017
6f61b5d
fix unit test
chengduoZH Sep 22, 2017
0417e4e
fix framework::LoDTensor => Tensor
chengduoZH Sep 22, 2017
c2c2d61
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
chengduoZH Sep 22, 2017
f2ccc11
fix pool doc (pool_op.cc)
chengduoZH Sep 22, 2017
b0a47b1
remove CHECK in *.cu
chengduoZH Sep 23, 2017
9b1431b
fix maxpool backward functor and add unit test
chengduoZH Sep 22, 2017
b728543
Fix (According to the review)
chengduoZH Sep 25, 2017
8c478b3
fix Atrr check
chengduoZH Sep 25, 2017
905a462
Merge branch 'fix_maxpool_backward_functor_temp' into Add_pool_op_temp
chengduoZH Sep 25, 2017
f6e69d7
fix maxpool backward functor
chengduoZH Sep 25, 2017
dfc8d3c
Fix (According to the review)
chengduoZH Sep 26, 2017
30a586d
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
chengduoZH Sep 26, 2017
4b06d8d
fix globalPooling type (int => bool)
chengduoZH Sep 26, 2017
3c0f079
remove conflict and fix InferShape function
chengduoZH Sep 27, 2017
e1e3859
remove custom attr checker and fix code format
chengduoZH Sep 29, 2017
df59889
remove conflict
chengduoZH Sep 29, 2017
2d8a5b9
fix unit test
chengduoZH Sep 29, 2017
6abcb74
fix unit test class name
chengduoZH Sep 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions paddle/operators/math/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
if(WITH_GPU)
nv_library(math_function SRCS math_function.cc math_function.cu im2col.cc im2col.cu pooling.cc pooling.cu DEPS cblas device_context)
nv_library(math_function SRCS math_function.cc math_function.cu im2col.cc im2col.cu pooling.cc pooling.cu DEPS cblas device_context operator)
nv_test(math_function_test SRCS math_function_test.cc DEPS math_function tensor)
nv_library(softmax SRCS softmax.cc softmax.cu DEPS operator)
nv_library(cross_entropy SRCS cross_entropy.cc cross_entropy.cu DEPS operator)
else()
cc_library(math_function SRCS math_function.cc im2col.cc pooling.cc
DEPS cblas device_context operator)
cc_library(math_function SRCS math_function.cc im2col.cc pooling.cc DEPS cblas device_context operator)
cc_test(math_function_test SRCS math_function_test.cc DEPS math_function tensor)
cc_library(softmax SRCS softmax.cc DEPS operator)
cc_library(cross_entropy SRCS cross_entropy.cc DEPS operator)
36 changes: 24 additions & 12 deletions python/paddle/v2/framework/tests/test_pool2d_op.py
Original file line number Diff line number Diff line change
@@ -47,7 +47,6 @@ def avg_pool2D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
class TestPool2d_Op(OpTest):
def setUp(self):
self.initTestCase()
self.op_type = "pool2d"
input = np.random.random(self.shape).astype("float32")
output = self.pool2D_forward_naive(input, self.ksize, self.strides,
self.paddings, self.global_pool)
@@ -71,7 +70,8 @@ def test_check_grad(self):
self.check_grad(set(['X']), 'Out', max_relative_error=0.07)

def initTestCase(self):
self.global_pool = 0
self.global_pool = True
self.op_type = "pool2d"
self.pool_type = "avg"
self.pool2D_forward_naive = avg_pool2D_forward_naive
self.shape = [2, 3, 5, 5]
@@ -82,47 +82,59 @@ def initTestCase(self):

class TestCase1(TestPool2d_Op):
def initTestCase(self):
self.global_pool = 0
self.global_pool = False
self.op_type = "pool2d"
self.pool_type = "avg"
self.pool2D_forward_naive = avg_pool2D_forward_naive
self.shape = [2, 3, 5, 5]
self.shape = [2, 3, 7, 7]
self.ksize = [3, 3]
self.strides = [1, 1]
self.paddings = [1, 1]
self.paddings = [0, 0]


class TestCase2(TestPool2d_Op):
def initTestCase(self):
self.global_pool = 1
self.global_pool = False
self.op_type = "pool2d"
self.pool_type = "avg"
self.pool2D_forward_naive = avg_pool2D_forward_naive
self.shape = [2, 3, 5, 5]
self.shape = [2, 3, 7, 7]
self.ksize = [3, 3]
self.strides = [1, 1]
self.paddings = [1, 1]


class TestCase3(TestPool2d_Op):
def initTestCase(self):
self.global_pool = 0
self.global_pool = True
self.op_type = "pool2d"
self.pool_type = "max"
self.pool2D_forward_naive = max_pool2D_forward_naive
self.shape = [2, 3, 5, 5]
self.ksize = [3, 3]
self.strides = [1, 1]
self.paddings = [1, 1]
self.paddings = [0, 0]


class TestCase4(TestPool2d_Op):
class TestCase3(TestPool2d_Op):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestCase3 repeated definition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def initTestCase(self):
self.global_pool = 1
self.global_pool = False
self.op_type = "pool2d"
self.pool_type = "max"
self.pool2D_forward_naive = max_pool2D_forward_naive
self.shape = [2, 3, 5, 5]
self.shape = [2, 3, 7, 7]
self.ksize = [3, 3]
self.strides = [1, 1]
self.paddings = [0, 0]


class TestCase3(TestPool2d_Op):
def initTestCase(self):
self.global_pool = False
self.op_type = "pool2d"
self.pool_type = "max"
self.pool2D_forward_naive = max_pool2D_forward_naive
self.shape = [2, 3, 7, 7]
self.ksize = [3, 3]
self.strides = [1, 1]
self.paddings = [1, 1]
32 changes: 22 additions & 10 deletions python/paddle/v2/framework/tests/test_pool3d_op.py
Original file line number Diff line number Diff line change
@@ -55,7 +55,6 @@ def avg_pool3D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
class TestPool3d_Op(OpTest):
def setUp(self):
self.initTestCase()
self.op_type = "pool3d"
input = np.random.random(self.shape).astype("float32")
output = self.pool3D_forward_naive(input, self.ksize, self.strides,
self.paddings, self.global_pool)
@@ -79,7 +78,8 @@ def test_check_grad(self):
self.check_grad(set(['X']), 'Out', max_relative_error=0.07)

def initTestCase(self):
self.global_pool = 0
self.global_pool = True
self.op_type = "pool3d"
self.pool_type = "avg"
self.pool3D_forward_naive = avg_pool3D_forward_naive
self.shape = [2, 3, 5, 5, 5]
@@ -90,19 +90,19 @@ def initTestCase(self):

class TestCase1(TestPool3d_Op):
def initTestCase(self):
self.global_pool = 0
self.global_pool = False
self.op_type = "pool3d"
self.pool_type = "avg"
self.pool3D_forward_naive = avg_pool3D_forward_naive
self.shape = [2, 3, 7, 7, 7]
self.ksize = [3, 3, 3]
self.strides = [1, 1, 1]
self.paddings = [1, 1, 1]
self.paddings = [0, 0, 0]


class TestCase2(TestPool3d_Op):
def initTestCase(self):
self.global_pool = 1
self.global_pool = False
self.op_type = "pool3d"
self.pool_type = "avg"
self.pool3D_forward_naive = avg_pool3D_forward_naive
@@ -114,23 +114,35 @@ def initTestCase(self):

class TestCase3(TestPool3d_Op):
def initTestCase(self):
self.global_pool = 0
self.global_pool = True
self.op_type = "pool3d"
self.pool_type = "max"
self.pool3D_forward_naive = max_pool3D_forward_naive
self.shape = [2, 3, 5, 5, 5]
self.ksize = [3, 3, 3]
self.strides = [1, 1, 1]
self.paddings = [1, 1, 1]
self.paddings = [0, 0, 0]


class TestCase4(TestPool3d_Op):
class TestCase3(TestPool3d_Op):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestCase4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def initTestCase(self):
self.global_pool = 1
self.global_pool = False
self.op_type = "pool3d"
self.pool_type = "max"
self.pool3D_forward_naive = max_pool3D_forward_naive
self.shape = [2, 3, 5, 5, 5]
self.shape = [2, 3, 7, 7, 7]
self.ksize = [3, 3, 3]
self.strides = [1, 1, 1]
self.paddings = [0, 0, 0]


class TestCase3(TestPool3d_Op):
def initTestCase(self):
self.global_pool = False
self.op_type = "pool3d"
self.pool_type = "max"
self.pool3D_forward_naive = max_pool3D_forward_naive
self.shape = [2, 3, 7, 7, 7]
self.ksize = [3, 3, 3]
self.strides = [1, 1, 1]
self.paddings = [1, 1, 1]