diff --git a/python/paddle/fluid/tests/unittests/op_test.py b/python/paddle/fluid/tests/unittests/op_test.py index cc2a54b95e224f31714c326eb7b5c434fbdab155..a54c8998ef06cedd3e76d247cc0e2e95eae2f46b 100644 --- a/python/paddle/fluid/tests/unittests/op_test.py +++ b/python/paddle/fluid/tests/unittests/op_test.py @@ -33,7 +33,7 @@ from paddle.fluid.executor import Executor from paddle.fluid.framework import Program, OpProtoHolder, Variable from testsuite import create_op, set_input, append_input_output, append_loss_ops from paddle.fluid import unique_name -from white_list import op_accuracy_white_list, op_check_grad_white_list, check_shape_white_list +from white_list import op_accuracy_white_list, op_check_grad_white_list, check_shape_white_list, compile_vs_runtime_white_list def _set_use_system_allocator(value=None): @@ -1102,7 +1102,7 @@ class OpTest(unittest.TestCase): equal_nan=False, check_dygraph=True, inplace_atol=None, - check_compile_vs_runtime=False): + check_compile_vs_runtime=True): self.__class__.op_type = self.op_type places = self._get_places() for place in places: @@ -1112,7 +1112,9 @@ class OpTest(unittest.TestCase): outs, dygraph_outs, fetch_list = res else: outs, fetch_list = res - if check_compile_vs_runtime: + if check_compile_vs_runtime and ( + self.op_type not in + compile_vs_runtime_white_list.COMPILE_RUN_OP_WHITE_LIST): self.check_compile_vs_runtime(fetch_list, outs) def check_output_customized(self, checker): diff --git a/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py b/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py new file mode 100644 index 0000000000000000000000000000000000000000..c7184633f1dba80937e443d48745ddcdcf2a3e0b --- /dev/null +++ b/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py @@ -0,0 +1,28 @@ +# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# If the output after infershape() is a lod_tensor, commenly its lod_level +# should be equal during compile time and run time. +# For ops in this whitelist, the equality check of lod_level between +# compiletime&runtime will not be required. +COMPILE_RUN_OP_WHITE_LIST = [ + 'lod_reset', 'sequence_pool', 'sequence_slice', 'generate_mask_labels', + 'sequence_reshape', 'generate_proposals', 'mine_hard_examples', + 'retinanet_detection_output', 'ctc_align', 'fusion_seqpool_cvm_concat', + 'gru', 'sequence_erase', 'rpn_target_assign', 'retinanet_target_assign', + 'filter_by_instag', 'fusion_seqpool_concat', 'multiclass_nms', + 'multiclass_nms2', 'im2sequence', 'generate_proposal_labels', + 'distribute_fpn_proposals', 'detection_map', 'locality_aware_nms', + 'var_conv_2d' +] diff --git a/tools/check_api_approvals.sh b/tools/check_api_approvals.sh index faedc75cc7608d91c16f841e59d13bc6ce3fe329..03d9335564520cb9217de2e5bc6d38852c2c4d69 100644 --- a/tools/check_api_approvals.sh +++ b/tools/check_api_approvals.sh @@ -168,6 +168,13 @@ if [ "${HAS_INPLACE_TESTS}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then check_approval 1 46782768 47554610 43953930 6836917 fi +HAS_COMPILERUNTIME_NOT_TEST=`git diff -U0 --diff-filter=A upstream/$BRANCH |grep "+" |grep -E "check_output[(]*check_compile_vs_runtime=False" || true` +if [ "${HAS_COMPILERUNTIME_NOT_TEST}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then + echo_line="If the operator's output after infershape() is a LodTensor, the output's Lod-Level during compile-time and runtime must be equal. Please set check_compile_vs_runtime=True in op_test.check_output function to enable compile&runtime lod-level check.\n +If you do not need check_compile_vs_runtime, you must have one RD (lanxianghit, phlrain, luotao1) approval.\nThe corresponding lines are as follows:\n${HAS_COMPILERUNTIME_NOT_TEST}\n" + check_approval 1 47554610 43953930 6836917 +fi + OP_FILE_CHANGED=`git diff --name-only --diff-filter=AMR upstream/$BRANCH |grep -oE ".+_op..*" || true` if [ "${OP_FILE_CHANGED}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then for OP_FILE in ${OP_FILE_CHANGED};