From 1daf1aafc432fb31f5292b50252b74ace6aaa753 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Sat, 23 Sep 2023 11:45:20 -0400 Subject: [PATCH] Add dot function for good measure --- _posts/2023-09-19-compiling-ml-models.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_posts/2023-09-19-compiling-ml-models.md b/_posts/2023-09-19-compiling-ml-models.md index 9f79a437..475fe6c8 100644 --- a/_posts/2023-09-19-compiling-ml-models.md +++ b/_posts/2023-09-19-compiling-ml-models.md @@ -1276,6 +1276,9 @@ nice speedup. The code for compiling a `Dot` node is not that tricky: ```python +def dot(l, r): + return sum(li.data*ri.data for li,ri in zip(l,r)) + class Dot(Value): def __init__(self, left_arr, right_arr): assert len(left_arr) == len(right_arr)