From a3535812f6d75ff197563c4bf7750af54e20cc04 Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Tue, 3 Dec 2019 20:33:20 +0800 Subject: [PATCH] add _use_system_allocator to some op tests, test=develop (#21504) --- .../fluid/tests/unittests/mkldnn/test_batch_norm_mkldnn_op.py | 4 +++- .../fluid/tests/unittests/ngraph/test_batch_norm_ngraph_op.py | 3 +++ python/paddle/fluid/tests/unittests/test_batch_norm_op.py | 4 +++- python/paddle/fluid/tests/unittests/test_layer_norm_op.py | 3 +++ .../paddle/fluid/tests/unittests/test_sync_batch_norm_op.py | 4 +++- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/mkldnn/test_batch_norm_mkldnn_op.py b/python/paddle/fluid/tests/unittests/mkldnn/test_batch_norm_mkldnn_op.py index eb12470789..2c8daf3817 100644 --- a/python/paddle/fluid/tests/unittests/mkldnn/test_batch_norm_mkldnn_op.py +++ b/python/paddle/fluid/tests/unittests/mkldnn/test_batch_norm_mkldnn_op.py @@ -19,11 +19,13 @@ import numpy as np import paddle.fluid.core as core from paddle.fluid.op import Operator import paddle.fluid as fluid -from paddle.fluid.tests.unittests.op_test import OpTest +from paddle.fluid.tests.unittests.op_test import OpTest, _set_use_system_allocator from paddle.fluid.framework import grad_var_name from paddle.fluid.tests.unittests.test_batch_norm_op import TestBatchNormOpInference, TestBatchNormOpTraining, _reference_training, _reference_grad from mkldnn_op_test import check_if_mkldnn_batchnorm_primitives_exist_in_bwd +_set_use_system_allocator(True) + class TestMKLDNNBatchNormOpTraining(TestBatchNormOpTraining): def init_kernel_type(self): diff --git a/python/paddle/fluid/tests/unittests/ngraph/test_batch_norm_ngraph_op.py b/python/paddle/fluid/tests/unittests/ngraph/test_batch_norm_ngraph_op.py index 34fb73f3cf..d9198114f3 100644 --- a/python/paddle/fluid/tests/unittests/ngraph/test_batch_norm_ngraph_op.py +++ b/python/paddle/fluid/tests/unittests/ngraph/test_batch_norm_ngraph_op.py @@ -16,6 +16,9 @@ from __future__ import print_function import unittest from paddle.fluid.tests.unittests.test_batch_norm_op import TestBatchNormOpTraining, TestBatchNormOpInference +from paddle.fluid.tests.unittests.op_test import _set_use_system_allocator + +_set_use_system_allocator(True) if __name__ == '__main__': unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_batch_norm_op.py b/python/paddle/fluid/tests/unittests/test_batch_norm_op.py index 851dfe39e4..7c445594c7 100644 --- a/python/paddle/fluid/tests/unittests/test_batch_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_batch_norm_op.py @@ -20,11 +20,13 @@ import numpy as np import paddle.fluid.core as core from paddle.fluid.op import Operator import paddle.fluid as fluid -from op_test import OpTest +from op_test import OpTest, _set_use_system_allocator from paddle.fluid.framework import grad_var_name import paddle.fluid as fluid from paddle.fluid import Program, program_guard +_set_use_system_allocator(True) + def _reference_testing(x, scale, offset, mean, var, epsilon, data_format): x_shape = x.shape diff --git a/python/paddle/fluid/tests/unittests/test_layer_norm_op.py b/python/paddle/fluid/tests/unittests/test_layer_norm_op.py index d5724b6e3c..4bd7a98cb9 100644 --- a/python/paddle/fluid/tests/unittests/test_layer_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_layer_norm_op.py @@ -20,9 +20,12 @@ from operator import mul import paddle.fluid.core as core import paddle.fluid as fluid from functools import reduce +from op_test import _set_use_system_allocator np.random.random(123) +_set_use_system_allocator(True) + def _reference_layer_norm_naive(x, scale, beta, epsilon, begin_norm_axis=1): x_shape = x.shape diff --git a/python/paddle/fluid/tests/unittests/test_sync_batch_norm_op.py b/python/paddle/fluid/tests/unittests/test_sync_batch_norm_op.py index a9eccf4a21..8fd118c019 100644 --- a/python/paddle/fluid/tests/unittests/test_sync_batch_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_sync_batch_norm_op.py @@ -26,7 +26,9 @@ import paddle.fluid.core as core import paddle.fluid as fluid from paddle.fluid import compiler -from op_test import OpTest +from op_test import OpTest, _set_use_system_allocator + +_set_use_system_allocator(True) def create_or_get_tensor(scope, var_name, var, place): -- GitLab