From 358f496549a8bf9d2102f3fd592bdaee40ebad38 Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Sun, 8 Nov 2020 15:56:43 +0000 Subject: [PATCH] Updated python lr impl to use sequence for more efficient management of sequences --- python/test/test_kompute.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/python/test/test_kompute.py b/python/test/test_kompute.py index fd66115..559600e 100644 --- a/python/test/test_kompute.py +++ b/python/test/test_kompute.py @@ -189,14 +189,20 @@ def test_logistic_regression_pyshader(): mgr.eval_tensor_create_def(params) + # Record commands for efficient evaluation + sq = mgr.create_sequence() + sq.begin() + sq.record_tensor_sync_device([tensor_w_in, tensor_b_in]) + sq.record_algo_data(params, compute_shader.to_spirv()) + sq.record_tensor_sync_local([tensor_w_out_i, tensor_w_out_j, tensor_b_out, tensor_l_out]) + sq.end() + ITERATIONS = 100 learning_rate = 0.1 # Perform machine learning training and inference across all input X and Y for i_iter in range(ITERATIONS): - mgr.eval_tensor_sync_device_def([tensor_w_in, tensor_b_in]) - mgr.eval_algo_data_def(params, compute_shader.to_spirv()) - mgr.eval_tensor_sync_local_def([tensor_w_out_i, tensor_w_out_j, tensor_b_out, tensor_l_out]) + sq.eval() # Calculate the parameters based on the respective derivatives calculated w_in_i_val = tensor_w_in.data()[0]