Skip to content

Commit

Permalink
Made python tests location agnostic whre they get called
Browse files Browse the repository at this point in the history
  • Loading branch information
axsaucedo committed Nov 9, 2020
1 parent b687e98 commit 8f09edf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include CMakeLists.txt
include LICENSE
recursive-include src *
recursive-include python *
recursive-include single_include *
Expand Down
15 changes: 12 additions & 3 deletions python/test/test_kompute.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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])

Expand All @@ -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():
Expand Down

0 comments on commit 8f09edf

Please sign in to comment.