Skip to content

Commit

Permalink
Merge branch 'PaddlePaddle:develop' into fan-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
WorgenZhang authored Jul 20, 2021
2 parents b231300 + 1f6f223 commit b4059e5
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def is_unsupported(func):
for v in m.__dict__.values():
func_in_dict = func == v
if isinstance(func_in_dict, (list, numpy.ndarray)):
func_in_dict = any(func_in_dict)
func_in_dict = numpy.array(func_in_dict).any()
if func_in_dict:
translator_logger.log(
2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,43 @@ def forward(self, x):
return out


class NestSequentialNet(paddle.nn.Layer):
def __init__(self):
super().__init__()
group1 = paddle.nn.Sequential(
paddle.nn.Linear(10, 10),
paddle.nn.Sigmoid(), )
group2 = paddle.nn.Sequential(
paddle.nn.Linear(10, 3),
paddle.nn.ReLU(), )
self.layers = paddle.nn.Sequential(group1, group2)

def forward(self, x):
return self.layers(x)


class TestSequential(unittest.TestCase):
def setUp(self):
paddle.set_device('cpu')
self.seed = 2021
self._init_config()

def _init_config(self):
self.net = SequentialNet(BufferLayers, 10, 3)
self.model_path = './sequential_net'

def _init_seed(self):
paddle.seed(self.seed)
np.random.seed(self.seed)

def _run(self, to_static):
self._init_seed()
net = SequentialNet(BufferLayers, 10, 3)
if to_static:
net = paddle.jit.to_static(net)
self.net = paddle.jit.to_static(self.net)
x = paddle.rand([16, 10], 'float32')
out = net(x)
out = self.net(x)
if to_static:
load_out = self._test_load(net, x)
load_out = self._test_load(self.net, x)
self.assertTrue(
np.allclose(load_out, out),
msg='load_out is {}\st_out is {}'.format(load_out, out))
Expand All @@ -80,12 +99,17 @@ def test_train(self):
msg='dygraph_res is {}\nstatic_res is {}'.format(dy_out, st_out))

def _test_load(self, net, x):
model_path = './sequential_net'
paddle.jit.save(net, model_path)
load_net = paddle.jit.load(model_path)
paddle.jit.save(net, self.model_path)
load_net = paddle.jit.load(self.model_path)
out = load_net(x)
return out


class TestNestSequential(TestSequential):
def _init_config(self):
self.net = NestSequentialNet()
self.model_path = './nested_sequential_net'


if __name__ == '__main__':
unittest.main()
12 changes: 0 additions & 12 deletions python/paddle/tests/test_dataset_cifar.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def test_main(self):
self.assertTrue(data.shape[2] == 3)
self.assertTrue(data.shape[1] == 32)
self.assertTrue(data.shape[0] == 32)
self.assertTrue(len(label.shape) == 1)
self.assertTrue(label.shape[0] == 1)
self.assertTrue(0 <= int(label) <= 9)


Expand All @@ -51,8 +49,6 @@ def test_main(self):
self.assertTrue(data.shape[2] == 3)
self.assertTrue(data.shape[1] == 32)
self.assertTrue(data.shape[0] == 32)
self.assertTrue(len(label.shape) == 1)
self.assertTrue(label.shape[0] == 1)
self.assertTrue(0 <= int(label) <= 9)

# test cv2 backend
Expand All @@ -67,8 +63,6 @@ def test_main(self):
self.assertTrue(data.shape[2] == 3)
self.assertTrue(data.shape[1] == 32)
self.assertTrue(data.shape[0] == 32)
self.assertTrue(len(label.shape) == 1)
self.assertTrue(label.shape[0] == 1)
self.assertTrue(0 <= int(label) <= 99)

with self.assertRaises(ValueError):
Expand All @@ -89,8 +83,6 @@ def test_main(self):
self.assertTrue(data.shape[2] == 3)
self.assertTrue(data.shape[1] == 32)
self.assertTrue(data.shape[0] == 32)
self.assertTrue(len(label.shape) == 1)
self.assertTrue(label.shape[0] == 1)
self.assertTrue(0 <= int(label) <= 99)


Expand All @@ -108,8 +100,6 @@ def test_main(self):
self.assertTrue(data.shape[2] == 3)
self.assertTrue(data.shape[1] == 32)
self.assertTrue(data.shape[0] == 32)
self.assertTrue(len(label.shape) == 1)
self.assertTrue(label.shape[0] == 1)
self.assertTrue(0 <= int(label) <= 99)

# test cv2 backend
Expand All @@ -124,8 +114,6 @@ def test_main(self):
self.assertTrue(data.shape[2] == 3)
self.assertTrue(data.shape[1] == 32)
self.assertTrue(data.shape[0] == 32)
self.assertTrue(len(label.shape) == 1)
self.assertTrue(label.shape[0] == 1)
self.assertTrue(0 <= int(label) <= 99)

with self.assertRaises(ValueError):
Expand Down
7 changes: 3 additions & 4 deletions python/paddle/vision/datasets/cifar.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ def _load_data(self):
six.b('labels'), batch.get(six.b('fine_labels'), None))
assert labels is not None
for sample, label in six.moves.zip(data, labels):
self.data.append((sample,
np.array([label]).astype('int64')))
self.data.append((sample, label))

def __getitem__(self, idx):
image, label = self.data[idx]
Expand All @@ -162,9 +161,9 @@ def __getitem__(self, idx):
image = self.transform(image)

if self.backend == 'pil':
return image, label.astype('int64')
return image, np.array(label).astype('int64')

return image.astype(self.dtype), label.astype('int64')
return image.astype(self.dtype), np.array(label).astype('int64')

def __len__(self):
return len(self.data)
Expand Down
17 changes: 16 additions & 1 deletion tools/dockerfile/build_scripts/install_trt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@

VERSION=$(nvcc --version | grep release | grep -oEi "release ([0-9]+)\.([0-9])"| sed "s/release //")

CUDNN_MAJOR=$(cat /usr/include/cudnn.h | grep -v CUDNN_VERSION | grep CUDNN_MAJOR | cut -d' ' -f3)
CUDNN_MINOR=$(cat /usr/include/cudnn.h | grep -v CUDNN_VERSION | grep CUDNN_MINOR | cut -d' ' -f3)
CUDNN_PATCHLEVEL=$(cat /usr/include/cudnn.h | grep -v CUDNN_VERSION | grep CUDNN_PATCHLEVEL | cut -d' ' -f3)
if [[ -z "${CUDNN_MAJOR}" ]]; then
CUDNN_MAJOR=$(cat /usr/include/cudnn_version.h | grep -v CUDNN_VERSION | grep CUDNN_MAJOR | cut -d' ' -f3)
CUDNN_MINOR=$(cat /usr/include/cudnn_version.h | grep -v CUDNN_VERSION | grep CUDNN_MINOR | cut -d' ' -f3)
CUDNN_PATCHLEVEL=$(cat /usr/include/cudnn_version.h | grep -v CUDNN_VERSION | grep CUDNN_PATCHLEVEL | cut -d' ' -f3)
fi
CUDNN_VERSION="${CUDNN_MAJOR}.${CUDNN_MINOR}.${CUDNN_PATCHLEVEL}"

if [[ "$VERSION" == "10.1" ]];then
wget -q https://paddle-ci.gz.bcebos.com/TRT/TensorRT6-cuda10.1-cudnn7.tar.gz --no-check-certificate
tar -zxf TensorRT6-cuda10.1-cudnn7.tar.gz -C /usr/local
Expand All @@ -36,7 +46,12 @@ elif [[ "$VERSION" == "11.0" ]];then
tar -zxf TensorRT-7.1.3.4.Ubuntu-16.04.x86_64-gnu.cuda-11.0.cudnn8.0.tar.gz -C /usr/local
cp -rf /usr/local/TensorRT-7.1.3.4/include/* /usr/include/ && cp -rf /usr/local/TensorRT-7.1.3.4/lib/* /usr/lib/
rm TensorRT-7.1.3.4.Ubuntu-16.04.x86_64-gnu.cuda-11.0.cudnn8.0.tar.gz
elif [[ "$VERSION" == "10.2" ]];then
elif [[ "$VERSION" == "10.2" && "$CUDNN_VERSION" == "7.6.5" ]];then
wget https://paddle-ci.gz.bcebos.com/TRT/TensorRT-6.0.1.8.CentOS-7.6.x86_64-gnu.cuda-10.2.cudnn7.6.tar.gz --no-check-certificate
tar -zxf TensorRT-6.0.1.8.CentOS-7.6.x86_64-gnu.cuda-10.2.cudnn7.6.tar.gz -C /usr/local
cp -rf /usr/local/TensorRT-6.0.1.8/include/* /usr/include/ && cp -rf /usr/local/TensorRT-6.0.1.8/lib/* /usr/lib/
rm -f TensorRT-6.0.1.8.CentOS-7.6.x86_64-gnu.cuda-10.2.cudnn7.6.tar.gz
elif [[ "$VERSION" == "10.2" && "$CUDNN_VERSION" == "8.1.1" ]];then
wget https://paddle-ci.gz.bcebos.com/TRT/TensorRT-7.2.3.4.CentOS-7.9.x86_64-gnu.cuda-10.2.cudnn8.1.tar.gz --no-check-certificate
tar -zxf TensorRT-7.2.3.4.CentOS-7.9.x86_64-gnu.cuda-10.2.cudnn8.1.tar.gz -C /usr/local
cp -rf /usr/local/TensorRT-7.2.3.4/include/* /usr/include/ && cp -rf /usr/local/TensorRT-7.2.3.4/lib/* /usr/lib/
Expand Down
8 changes: 8 additions & 0 deletions tools/dockerfile/centos7_manylinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ function make_cuda102cudnn7() {
sed -i "s#RUN bash build_scripts/build.sh#RUN bash build_scripts/install_gcc.sh gcc82 \nRUN mv /usr/bin/cc /usr/bin/cc.bak \&\& ln -s /usr/local/gcc-8.2/bin/gcc /usr/bin/cc \nENV PATH=/usr/local/gcc-8.2/bin:\$PATH \nRUN bash build_scripts/build.sh#g" Dockerfile.tmp
}

function make_cuda102cudnn7gcc54() {
sed 's/<baseimg>/10.2-cudnn7-devel-centos7/g' Dockerfile.centos >Dockerfile.tmp
sed -i "s#RUN bash build_scripts/build.sh#RUN bash build_scripts/install_gcc.sh gcc54 \nRUN mv /usr/bin/cc /usr/bin/cc.bak \&\& ln -s /usr/local/gcc-8.2/bin/gcc /usr/bin/cc \nENV PATH=/usr/local/gcc-8.2/bin:\$PATH \nRUN bash build_scripts/build.sh#g" Dockerfile.tmp
}

function make_cuda102cudnn8() {
sed 's/<baseimg>/10.2-cudnn8-devel-centos7/g' Dockerfile.centos >Dockerfile.tmp
sed -i "s#RUN bash build_scripts/build.sh#RUN bash build_scripts/install_gcc.sh gcc82 \nRUN mv /usr/bin/cc /usr/bin/cc.bak \&\& ln -s /usr/local/gcc-8.2/bin/gcc /usr/bin/cc \nENV PATH=/usr/local/gcc-8.2/bin:\$PATH \nRUN bash build_scripts/build.sh#g" Dockerfile.tmp
Expand Down Expand Up @@ -94,6 +99,9 @@ function main() {
cuda102cudnn7)
make_cuda102cudnn7
;;
cuda102cudnn7gcc54)
make_cuda102cudnn7gcc54
;;
cuda102cudnn8)
make_cuda102cudnn8
;;
Expand Down

1 comment on commit b4059e5

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

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

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.