interplane.Get Omega
Read in your language

ggml

[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)

Brought by drakestapleton

branch master Branches Tags History

ggml / examples / simple / README.md

61 lines · 1078 bytes Raw Blame History Rendered
1## Simple
2
3This example simply performs a matrix multiplication, solely for the purpose of demonstrating a basic usage of ggml and backend handling. The code is commented to help understand what each part does.
4
5Traditional matrix multiplication goes like this (multiply row-by-column):
6
7$$
8A \times B = C
9$$
10
11$$
12\begin{bmatrix}
132 & 8 \\
145 & 1 \\
154 & 2 \\
168 & 6 \\
17\end{bmatrix}
18\times
19\begin{bmatrix}
2010 & 9 & 5 \\
215 & 9 & 4 \\
22\end{bmatrix}
23\=
24\begin{bmatrix}
2560 & 90 & 42 \\
2655 & 54 & 29 \\
2750 & 54 & 28 \\
28110 & 126 & 64 \\
29\end{bmatrix}
30$$
31
32In `ggml`, we pass the matrix $B$ in transposed form and multiply row-by-row. The result $C$ is also transposed:
33
34$$
35ggml\\_mul\\_mat(A, B^T) = C^T
36$$
37
38$$
39ggml\\_mul\\_mat(
40\begin{bmatrix}
412 & 8 \\
425 & 1 \\
434 & 2 \\
448 & 6 \\
45\end{bmatrix}
46,
47\begin{bmatrix}
4810 & 5 \\
499 & 9 \\
505 & 4 \\
51\end{bmatrix}
52)
53\=
54\begin{bmatrix}
5560 & 55 & 50 & 110 \\
5690 & 54 & 54 & 126 \\
5742 & 29 & 28 & 64 \\
58\end{bmatrix}
59$$
60
61The `simple-ctx` doesn't support gpu acceleration. `simple-backend` demonstrates how to use other backends like CUDA and Metal.