From 8f09edf49df7b30cdb588a832cbd9b09c3b8a020 Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Mon, 9 Nov 2020 19:58:27 +0000 Subject: [PATCH] Made python tests location agnostic whre they get called --- MANIFEST.in | 1 + python/test/test_kompute.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index e9f375e3..ffcfe6f0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include CMakeLists.txt +include LICENSE recursive-include src * recursive-include python * recursive-include single_include * diff --git a/python/test/test_kompute.py b/python/test/test_kompute.py index ea82799e..7d201f2f 100644 --- a/python/test/test_kompute.py +++ b/python/test/test_kompute.py @@ -1,9 +1,12 @@ +import os from pyshader import python2shader, f32, ivec3, Array from pyshader.stdlib import exp, log from kp import Tensor, Manager, Sequence +DIRNAME = os.path.dirname(os.path.abspath(__file__)) + def test_opmult(): """ Test basic OpMult operation @@ -70,7 +73,7 @@ def test_opalgobase_file(): mgr = Manager() - shaderFilePath = "../../shaders/glsl/opmult.comp" + shaderFilePath = os.path.join(DIRNAME, "../../shaders/glsl/opmult.comp") mgr.eval_tensor_create_def([tensor_in_a, tensor_in_b, tensor_out]) @@ -85,20 +88,26 @@ def test_sequence(): Test basic OpAlgoBase operation """ mgr = Manager(0, [2]) + tensor_in_a = Tensor([2, 2, 2]) tensor_in_b = Tensor([1, 2, 3]) tensor_out = Tensor([0, 0, 0]) + mgr.eval_tensor_create_def([tensor_in_a, tensor_in_b, tensor_out]) - seq = mgr.create_sequence("op") - shaderFilePath = "../../shaders/glsl/opmult.comp" + + shaderFilePath = os.path.join(DIRNAME, "../../shaders/glsl/opmult.comp") mgr.eval_async_algo_file_def([tensor_in_a, tensor_in_b, tensor_out], shaderFilePath) + mgr.eval_await_def() + + seq = mgr.create_sequence("op") seq.begin() seq.record_tensor_sync_local([tensor_in_a]) seq.record_tensor_sync_local([tensor_in_b]) seq.record_tensor_sync_local([tensor_out]) seq.end() seq.eval() + assert tensor_out.data() == [2.0, 4.0, 6.0] def test_pyshader_pyshader():