Skip to content

Commit a24eda8

Browse files
jan-wassenbergcopybara-github
authored andcommitted
Split matmul into matvec; add large matrix benchmark
Rename var names to row/col for more clarity. Better estimate error tolerance via max abs col sum. PiperOrigin-RevId: 657601791
1 parent d37c088 commit a24eda8

8 files changed

Lines changed: 717 additions & 569 deletions

File tree

BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ cc_library(
2525
textual_hdrs = [
2626
"ops/ops-inl.h",
2727
"ops/matmul-inl.h",
28+
"ops/matvec-inl.h",
2829
],
2930
deps = [
3031
"//compression:compress",
@@ -56,6 +57,25 @@ cc_test(
5657
],
5758
)
5859

60+
cc_test(
61+
name = "matvec_test",
62+
size = "small",
63+
timeout = "long",
64+
srcs = ["ops/matvec_test.cc"],
65+
local_defines = ["HWY_IS_TEST"],
66+
# for test_suite.
67+
tags = ["hwy_ops_test"],
68+
deps = [
69+
":ops",
70+
"@googletest//:gtest_main", # buildcleaner: keep
71+
"//compression:compress",
72+
"@hwy//:hwy",
73+
"@hwy//:hwy_test_util",
74+
"@hwy//:nanobenchmark",
75+
"@hwy//:thread_pool",
76+
],
77+
)
78+
5979
cc_test(
6080
name = "matmul_test",
6181
size = "small",

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ set(SOURCES
9898
gemma/weights.cc
9999
gemma/weights.h
100100
ops/matmul-inl.h
101+
ops/matvec-inl.h
101102
ops/ops-inl.h
102103
util/app.h
103104
util/args.h
@@ -148,7 +149,9 @@ set(GEMMA_TEST_FILES
148149
backprop/backward_test.cc
149150
backprop/backward_scalar_test.cc
150151
backprop/optimize_test.cc
151-
gemma/ops_test.cc
152+
ops/ops_test.cc
153+
ops/matmul_test.cc
154+
ops/matvec_test.cc
152155
evals/gemma_test.cc
153156
)
154157

backprop/forward-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define THIRD_PARTY_GEMMA_CPP_FORWARD_TOGGLE
4040
#endif
4141

42-
#include "ops/matmul-inl.h"
42+
#include "ops/matvec-inl.h"
4343
#include "ops/ops-inl.h"
4444
#include "hwy/highway.h"
4545

gemma/gemma-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
#include "gemma/weights.h"
4141
// Placeholder for internal test4, do not remove
4242
#include "ops/matmul-inl.h"
43+
#include "ops/matvec-inl.h"
4344
#include "ops/ops-inl.h"
4445
#include "hwy/aligned_allocator.h"
4546
#include "hwy/base.h"
4647
#include "hwy/bit_set.h"
47-
#include "hwy/contrib/matvec/matvec-inl.h"
4848
#include "hwy/contrib/thread_pool/thread_pool.h"
4949
#include "hwy/contrib/thread_pool/topology.h"
5050
#include "hwy/highway.h"

0 commit comments

Comments
 (0)