From 6aace600f201f206d92af34cd7a93f732bf85978 Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Thu, 12 Sep 2019 18:35:25 +0200 Subject: [PATCH] Let all Tensorflow compilation test pass by using different function names --- tests/test_native_tensorflow_compilation.py | 12 ++++---- tests/test_tensorflow_jit.py | 31 ++++++++++----------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/test_native_tensorflow_compilation.py b/tests/test_native_tensorflow_compilation.py index f8c5c8d..705d722 100644 --- a/tests/test_native_tensorflow_compilation.py +++ b/tests/test_native_tensorflow_compilation.py @@ -108,9 +108,9 @@ def test_native_tensorflow_compilation_gpu(): backward_assignments = create_backward_assignments(forward_assignments) forward_ast = pystencils.create_kernel(forward_assignments, target) - forward_ast.function_name = 'forward' + forward_ast.function_name = 'forward2' backward_ast = pystencils.create_kernel(backward_assignments, target) - backward_ast.function_name = 'backward' + backward_ast.function_name = 'backward2' module = TensorflowModule(module_name, [forward_ast, backward_ast]) print(str(module)) @@ -144,10 +144,10 @@ def test_native_tensorflow_compilation_gpu(): # command = ['clang-7', '-shared', temp_file.name, '--cuda-path=/usr/include', '-std=c++14', # '-fPIC', '-lcudart', '-o', 'foo.so'] + compile_flags + link_flags + extra_flags command = ['c++', '-fPIC', '-lcudart', 'foo_gpu.o', - '-shared', '-o', 'foo.so'] + link_flags + '-shared', '-o', 'foo_gpu.so'] + link_flags subprocess.check_call(command) - lib = tf.load_op_library(join(os.getcwd(), 'foo.so')) + lib = tf.load_op_library(join(os.getcwd(), 'foo_gpu.so')) - assert 'call_forward' in dir(lib) - assert 'call_backward' in dir(lib) + assert 'call_forward2' in dir(lib) + assert 'call_backward2' in dir(lib) diff --git a/tests/test_tensorflow_jit.py b/tests/test_tensorflow_jit.py index 251cbb2..187aa96 100644 --- a/tests/test_tensorflow_jit.py +++ b/tests/test_tensorflow_jit.py @@ -17,13 +17,13 @@ from pystencils_autodiff import create_backward_assignments from pystencils_autodiff.backends.astnodes import TensorflowModule -def test_tensorflow_jit_cpu(): +def test_tensorflow_jit_gpu(): pytest.importorskip('tensorflow') - module_name = "Ololol" + module_name = "Ololols" - target = 'cpu' + target = 'gpu' z, y, x = pystencils.fields("z, y, x: [20,40]") a = sympy.Symbol('a') @@ -35,23 +35,23 @@ def test_tensorflow_jit_cpu(): backward_assignments = create_backward_assignments(forward_assignments) forward_ast = pystencils.create_kernel(forward_assignments, target) - forward_ast.function_name = 'forward' + forward_ast.function_name = 'forward_jit_gpu' # must be different from CPU names backward_ast = pystencils.create_kernel(backward_assignments, target) - backward_ast.function_name = 'backward' + backward_ast.function_name = 'backward_jit_gpu' module = TensorflowModule(module_name, [forward_ast, backward_ast]) - lib = pystencils_autodiff.tensorflow_jit.compile_sources_and_load([str(module)]) - assert 'call_forward' in dir(lib) - assert 'call_backward' in dir(lib) + lib = pystencils_autodiff.tensorflow_jit.compile_sources_and_load([], [str(module)]) + assert 'call_forward_jit_gpu' in dir(lib) + assert 'call_backward_jit_gpu' in dir(lib) -def test_tensorflow_jit_gpu(): +def test_tensorflow_jit_cpu(): pytest.importorskip('tensorflow') module_name = "Ololol" - target = 'gpu' + target = 'cpu' z, y, x = pystencils.fields("z, y, x: [20,40]") a = sympy.Symbol('a') @@ -63,12 +63,11 @@ def test_tensorflow_jit_gpu(): backward_assignments = create_backward_assignments(forward_assignments) forward_ast = pystencils.create_kernel(forward_assignments, target) - forward_ast.function_name = 'forward' + forward_ast.function_name = 'forward_jit' backward_ast = pystencils.create_kernel(backward_assignments, target) - backward_ast.function_name = 'backward' + backward_ast.function_name = 'backward_jit' module = TensorflowModule(module_name, [forward_ast, backward_ast]) - lib = pystencils_autodiff.tensorflow_jit.compile_sources_and_load([], [str(module)]) - assert 'call_forward' in dir(lib) - assert 'call_backward' in dir(lib) - + lib = pystencils_autodiff.tensorflow_jit.compile_sources_and_load([str(module)]) + assert 'call_forward_jit' in dir(lib) + assert 'call_backward_jit' in dir(lib) -- GitLab