From 60c43ced4ab328ce59fd68d7a75574b9798fbbae Mon Sep 17 00:00:00 2001 From: Andrey Miroshnikov Date: Wed, 11 Oct 2023 11:16:34 +0000 Subject: [PATCH] Add pure python matrix mul function --- src/openpower/decoder/isa/test_caller_svp64_matrix.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/openpower/decoder/isa/test_caller_svp64_matrix.py b/src/openpower/decoder/isa/test_caller_svp64_matrix.py index 007c4cb3..05d755de 100644 --- a/src/openpower/decoder/isa/test_caller_svp64_matrix.py +++ b/src/openpower/decoder/isa/test_caller_svp64_matrix.py @@ -9,6 +9,16 @@ from openpower.decoder.selectable_int import SelectableInt from openpower.simulator.program import Program from openpower.insndb.asm import SVP64Asm +# Pure Python implementation of matrix multiply +# Example values +# x = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]] +# y = [[1,2],[1,2],[3,4]] +def matmult(a,b): + zip_b = zip(*b) + # uncomment next line if python 3 : + zip_b = list(zip_b) + return [[sum(ele_a*ele_b for ele_a, ele_b in zip(row_a, col_b)) + for col_b in zip_b] for row_a in a] class DecoderTestCase(FHDLTestCase): -- 2.30.2