Skip to content

Commit

Permalink
update ut, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sandyhouse committed Jun 30, 2020
1 parent 0938bc9 commit 5c865ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 113 deletions.
94 changes: 0 additions & 94 deletions python/paddle/fluid/tests/unittests/multi_process_data_norm.py

This file was deleted.

6 changes: 0 additions & 6 deletions python/paddle/fluid/tests/unittests/test_data_norm_op_sync.sh

This file was deleted.

22 changes: 9 additions & 13 deletions python/paddle/fluid/tests/unittests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import unittest
import math

gpu1_id = 0


def conv_bn_layer(input, num_filters, filter_size, stride=1, groups=1,
act=None):
Expand Down Expand Up @@ -91,8 +89,7 @@ def build_network(input, layers=50, class_dim=1000):
elif layers == 152:
depth = [3, 8, 36, 3]
num_filters = [64, 128, 256, 512]
offset = 0
with fluid.device_guard("gpu:%d" % (gpu1_id + offset)):
with fluid.device_guard("cpu"):
conv = conv_bn_layer(
input=input, num_filters=64, filter_size=7, stride=2, act='relu')
conv = fluid.layers.pool2d(
Expand All @@ -103,14 +100,14 @@ def build_network(input, layers=50, class_dim=1000):
pool_type='max')
if layers >= 50:
for block in range(len(depth)):
with fluid.device_guard("gpu:%d" % (gpu1_id + offset)):
with fluid.device_guard("cpu"):
for i in range(depth[block]):
conv = bottleneck_block(
input=conv,
num_filters=num_filters[block],
stride=2 if i == 0 and block != 0 else 1)

with fluid.device_guard("gpu:%d" % (gpu1_id + offset)):
with fluid.device_guard("gpu:0"):
pool = fluid.layers.pool2d(
input=conv, pool_size=7, pool_type='avg', global_pooling=True)
stdv = 1.0 / math.sqrt(pool.shape[1] * 1.0)
Expand All @@ -121,14 +118,14 @@ def build_network(input, layers=50, class_dim=1000):
initializer=fluid.initializer.Uniform(-stdv, stdv)))
else:
for block in range(len(depth)):
with fluid.device_guard("gpu:%d" % (gpu1_id + offset)):
with fluid.device_guard("cpu"):
for i in range(depth[block]):
conv = basic_block(
input=conv,
num_filters=num_filters[block],
stride=2 if i == 0 and block != 0 else 1,
is_first=block == i == 0)
with fluid.device_guard("gpu:%d" % (gpu1_id + offset)):
with fluid.device_guard("gpu:0"):
pool = fluid.layers.pool2d(
input=conv, pool_size=7, pool_type='avg', global_pooling=True)
stdv = 1.0 / math.sqrt(pool.shape[1] * 1.0)
Expand All @@ -137,15 +134,14 @@ def build_network(input, layers=50, class_dim=1000):
size=class_dim,
param_attr=fluid.param_attr.ParamAttr(
initializer=fluid.initializer.Uniform(-stdv, stdv)))
offset += 1
return out, offset
return out


class TestPipeline(unittest.TestCase):
""" TestCases for Pipeline Training. """

def test_pipeline(self):
with fluid.device_guard("gpu:%d" % gpu1_id):
with fluid.device_guard("cpu"):
image = fluid.layers.data(
name="image", shape=[3, 224, 224], dtype="float32")
label = fluid.layers.data(name="label", shape=[1], dtype="int64")
Expand All @@ -154,8 +150,8 @@ def test_pipeline(self):
capacity=64,
use_double_buffer=True,
iterable=False)
fc, offset = build_network(image, layers=50)
with fluid.device_guard("gpu:%d" % (gpu1_id + offset)):
fc = build_network(image, layers=50)
with fluid.device_guard("gpu:0"):
out, prob = fluid.layers.softmax_with_cross_entropy(
logits=fc, label=label, return_softmax=True)
loss = fluid.layers.mean(out)
Expand Down

0 comments on commit 5c865ab

Please sign in to comment.