From f26a1c9077f2f82cbe61d5e4f285affbf71b733b Mon Sep 17 00:00:00 2001 From: sneaxiy Date: Thu, 31 Jan 2019 07:21:55 +0000 Subject: [PATCH] test=develop --- paddle/fluid/operators/norm_op.h | 5 ++--- .../tests/unittests/test_eager_deletion_transformer.py | 8 +++----- .../tests/unittests/test_parallel_executor_transformer.py | 2 +- python/paddle/fluid/tests/unittests/transformer_model.py | 3 ++- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/paddle/fluid/operators/norm_op.h b/paddle/fluid/operators/norm_op.h index 6c95d3f3b..f81cbc2c7 100644 --- a/paddle/fluid/operators/norm_op.h +++ b/paddle/fluid/operators/norm_op.h @@ -99,10 +99,10 @@ class NormGradKernel : public framework::OpKernel { auto dx_e = framework::EigenVector::Flatten(*out_dx); Eigen::DSizes shape(pre, n, post); - Eigen::DSizes norm_shape(pre, post); + Eigen::DSizes rshape(pre, 1, post); auto x = x_e.reshape(shape); auto dy = dy_e.reshape(shape); - auto norm = norm_e.reshape(norm_shape); + auto norm = norm_e.reshape(rshape); auto dx = dx_e.reshape(shape); framework::Tensor rsum; @@ -111,7 +111,6 @@ class NormGradKernel : public framework::OpKernel { Eigen::DSizes rdim(1); Eigen::DSizes bcast(1, n, 1); - Eigen::DSizes rshape(pre, 1, post); // dx = ( dy/sqrt(sum(x*x)) ) * [1 - x*sum(x) / (sum(x*x) + e)] // = [dy - dy * x * sum(x) / (sum(x*x) + e)] / sqrt(sum(x*x)) diff --git a/python/paddle/fluid/tests/unittests/test_eager_deletion_transformer.py b/python/paddle/fluid/tests/unittests/test_eager_deletion_transformer.py index 754d5fd40..603c8e748 100644 --- a/python/paddle/fluid/tests/unittests/test_eager_deletion_transformer.py +++ b/python/paddle/fluid/tests/unittests/test_eager_deletion_transformer.py @@ -16,12 +16,10 @@ import os import unittest os.environ['FLAGS_eager_delete_tensor_gb'] = "0.0" -from test_parallel_executor_transformer import TestTransformer - - -class EagerDeletionTestTransformer(TestTransformer): - pass +os.environ[ + 'RECORDIO_FILENAME'] = '/tmp/eager_deletion_transformer.wmt16.recordio' +from test_parallel_executor_transformer import TestTransformer if __name__ == '__main__': unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_parallel_executor_transformer.py b/python/paddle/fluid/tests/unittests/test_parallel_executor_transformer.py index 382774390..aacc1c3ec 100644 --- a/python/paddle/fluid/tests/unittests/test_parallel_executor_transformer.py +++ b/python/paddle/fluid/tests/unittests/test_parallel_executor_transformer.py @@ -24,7 +24,7 @@ import paddle.fluid.core as core import paddle.dataset.wmt16 as wmt16 import os -WMT16_RECORDIO_FILE = "/tmp/wmt16.recordio" +WMT16_RECORDIO_FILE = os.environ.get('RECORDIO_FILENAME', '/tmp/wmt16.recordio') class ModelHyperParams(object): diff --git a/python/paddle/fluid/tests/unittests/transformer_model.py b/python/paddle/fluid/tests/unittests/transformer_model.py index 143d187ed..905b7d6fe 100644 --- a/python/paddle/fluid/tests/unittests/transformer_model.py +++ b/python/paddle/fluid/tests/unittests/transformer_model.py @@ -17,6 +17,7 @@ from __future__ import print_function from functools import partial import numpy as np +import os import paddle.fluid as fluid import paddle.fluid.layers as layers from paddle.fluid.layers.io import open_recordio_file @@ -408,7 +409,7 @@ def transformer( trg_pad_idx, pos_pad_idx, ): file_obj = open_recordio_file( - filename='/tmp/wmt16.recordio', + filename=os.environ.get('RECORDIO_FILENAME', '/tmp/wmt16.recordio'), shapes=[ [batch_size * max_length, 1], [batch_size * max_length, 1], -- GitLab