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

reduce unittest gpu memory #3448

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions python/paddle/v2/framework/tests/test_add_two_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class TestAddOp(unittest.TestCase):
def setUp(self):
self.type = "add_two"
self.inputs = {
'X': numpy.random.random((102, 105)).astype("float32"),
'Y': numpy.random.random((102, 105)).astype("float32")
'X': numpy.random.random((12, 15)).astype("float32"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add cases like

  • [7, 0]
  • [0, 7]
  • [0, 0]
  • [7, 13]

7 and 13 are just small prime numbers.

'Y': numpy.random.random((12, 15)).astype("float32")
}
self.outputs = {'Out': self.inputs['X'] + self.inputs['Y']}

Expand Down
4 changes: 2 additions & 2 deletions python/paddle/v2/framework/tests/test_cross_entropy_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestCrossEntropy(unittest.TestCase):
def setUp(self):
# TODO this unit test is not passed
self.type = "onehot_cross_entropy"
batch_size = 100
batch_size = 32
class_num = 10
X = numpy.random.random((batch_size, class_num)).astype("float32")
label = 5 * numpy.ones(batch_size).astype("int32")
Expand All @@ -24,7 +24,7 @@ def setUp(self):
class CrossEntropyGradOpTest(GradientChecker):
def test_softmax_grad(self):
op = create_op("onehot_cross_entropy")
batch_size = 100
batch_size = 32
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add test case with batch size = 0./

class_num = 10
inputs = {
"X": numpy.random.uniform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TestFillZerosLikeOp(unittest.TestCase):

def setUp(self):
self.type = "fill_zeros_like"
self.inputs = {'Src': numpy.random.random((219, 232)).astype("float32")}
self.inputs = {'Src': numpy.random.random((29, 22)).astype("float32")}
self.outputs = {'Dst': numpy.zeros_like(self.inputs['Src'])}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def gaussian_random_test(self, place):
op = Operator(
"gaussian_random",
Out="Out",
dims=[1000, 784],
dims=[10, 24],
mean=.0,
std=1.,
seed=10)
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/v2/framework/tests/test_mean_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TestMeanOp(unittest.TestCase):

def setUp(self):
self.type = "mean"
self.inputs = {'X': np.random.random((32, 784)).astype("float32")}
self.inputs = {'X': np.random.random((32, 84)).astype("float32")}
self.outputs = {'Out': np.mean(self.inputs['X'])}


Expand Down
4 changes: 2 additions & 2 deletions python/paddle/v2/framework/tests/test_mul_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class TestMulOp(unittest.TestCase):
def setUp(self):
self.type = "mul"
self.inputs = {
'X': np.random.random((32, 84)).astype("float32"),
'Y': np.random.random((84, 100)).astype("float32")
'X': np.random.random((32, 24)).astype("float32"),
'Y': np.random.random((24, 10)).astype("float32")
}
self.outputs = {'Out': np.dot(self.inputs['X'], self.inputs['Y'])}

Expand Down
4 changes: 2 additions & 2 deletions python/paddle/v2/framework/tests/test_rowwise_add_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class TestRowwiseAddOp(unittest.TestCase):
def setUp(self):
self.type = "rowwise_add"
self.inputs = {
'X': np.random.random((32, 84)).astype("float32"),
'b': np.random.random(84).astype("float32")
'X': np.random.random((32, 24)).astype("float32"),
'b': np.random.random(24).astype("float32")
}
self.outputs = {'Out': np.add(self.inputs['X'], self.inputs['b'])}

Expand Down
4 changes: 2 additions & 2 deletions python/paddle/v2/framework/tests/test_sgd_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class TestSGD(unittest.TestCase):

def setUp(self):
self.type = "sgd"
w = numpy.random.random((102, 105)).astype("float32")
g = numpy.random.random((102, 105)).astype("float32")
w = numpy.random.random((12, 15)).astype("float32")
g = numpy.random.random((12, 15)).astype("float32")
lr = 0.1

self.inputs = {'param': w, 'grad': g}
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/v2/framework/tests/test_sigmoid_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TestSigmoidOp(unittest.TestCase):

def setUp(self):
self.type = "sigmoid"
self.inputs = {'X': np.random.random((32, 100)).astype("float32")}
self.inputs = {'X': np.random.random((32, 18)).astype("float32")}
self.outputs = {'Y': 1 / (1 + np.exp(-self.inputs['X']))}


Expand Down
2 changes: 1 addition & 1 deletion python/paddle/v2/framework/tests/test_softmax_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TestSoftmaxOp(unittest.TestCase):

def setUp(self):
self.type = "softmax"
self.inputs = {'X': np.random.random((32, 100)).astype("float32")}
self.inputs = {'X': np.random.random((32, 22)).astype("float32")}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let us use small prime numbers.

self.outputs = {
'Y': np.apply_along_axis(stable_softmax, 1, self.inputs['X'])
}
Expand Down
8 changes: 4 additions & 4 deletions python/paddle/v2/framework/tests/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def test_int_tensor(self):

tensor = var.get_tensor()

tensor.set_dims([1000, 784])
tensor.set_dims([100, 84])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you try three configurations -- [7, 0], [0, 7], [7,13] -- 7 and 13 are just small prime numbers. Prime numbers are reasonable becaue they are not power of 2 or any way defactorizable. 0 is a good boundary case.

tensor.alloc_int(place)
tensor_array = numpy.array(tensor)
self.assertEqual((1000, 784), tensor_array.shape)
self.assertEqual((100, 84), tensor_array.shape)
tensor_array[3, 9] = 1
tensor_array[19, 11] = 2
tensor.set(tensor_array, place)
Expand All @@ -30,11 +30,11 @@ def test_float_tensor(self):

tensor = var.get_tensor()

tensor.set_dims([1000, 784])
tensor.set_dims([100, 84])
tensor.alloc_float(place)

tensor_array = numpy.array(tensor)
self.assertEqual((1000, 784), tensor_array.shape)
self.assertEqual((100, 84), tensor_array.shape)
tensor_array[3, 9] = 1.0
tensor_array[19, 11] = 2.0
tensor.set(tensor_array, place)
Expand Down