Created by: Xreki
目前Paddle框架缺乏有效的机制来保证compile-time和runtime信息的一致性。故,在op_test里面增加compile-time和runtime信息的检查,目前主要检查当输出LoDTensor时,compile-time和runtime的lod_level是否一致。比如sequence_resghape
op的InferShape
中没有传递lod_level,所以compile-time输出的lod_level是0,但具体实现的Kernel中有给输出Tensor设置了lod,导致了compile-time和runtime的lod_level信息不一致。op单测会出现如下错误:
473: ======================================================================
473: FAIL: test_check_output (test_sequence_reshape.TestSequenceReshape)
473: ----------------------------------------------------------------------
473: Traceback (most recent call last):
473: File "/paddle/build_paddle/build_docker_manylinux_cuda9.0/python/paddle/fluid/tests/unittests/test_sequence_reshape.py", line 50, in test_check_output
473: self.check_output()
473: File "/paddle/build_paddle/build_docker_manylinux_cuda9.0/python/paddle/fluid/tests/unittests/op_test.py", line 916, in check_output
473: self.check_compile_vs_runtime(fetch_list, outs)
473: File "/paddle/build_paddle/build_docker_manylinux_cuda9.0/python/paddle/fluid/tests/unittests/op_test.py", line 873, in check_compile_vs_runtime
473: ")")
473: AssertionError: The lod_level of Output (Out) is different between compile-time and runtime (0 vs 1)
这个PR为OpTest
的check_output
增加了一个参数check_compile_vs_runtime
:
def check_output(self,
atol=1e-5,
no_check_set=None,
equal_nan=False,
check_dygraph=False,
inplace_atol=None,
check_compile_vs_runtime=True):
我会先将check_compile_vs_runtime
的默认值设置成True
跑一遍,看看哪些op存在compile-time、runtime的lod_level不一致的问题。
此外:
- LoDTensorArray也是有lod_level的,目前没加入检查。