From: Andrey Miroshnikov Date: Wed, 11 Oct 2023 11:16:34 +0000 (+0000) Subject: Add pure python matrix mul function X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=60c43ced4ab328ce59fd68d7a75574b9798fbbae;p=openpower-isa.git Add pure python matrix mul function --- 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):