MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / test_add

Method test_add

external/ggml/examples/python/test_tensor.py:215–232  ·  view source on GitHub ↗
(self, ctx)

Source from the content-addressed store, hash-verified

213class TestGraph:
214
215 def test_add(self, ctx):
216 n = 256
217 ta = lib.ggml_new_tensor_1d(ctx, lib.GGML_TYPE_F32, n)
218 tb = lib.ggml_new_tensor_1d(ctx, lib.GGML_TYPE_F32, n)
219 tsum = lib.ggml_add(ctx, ta, tb)
220 assert tsum.type == lib.GGML_TYPE_F32
221
222 gf = ffi.new('struct ggml_cgraph*')
223 lib.ggml_build_forward_expand(gf, tsum)
224
225 a = np.arange(0, n, dtype=np.float32)
226 b = np.arange(n, 0, -1, dtype=np.float32)
227 copy(a, ta)
228 copy(b, tb)
229
230 lib.ggml_graph_compute_with_ctx(ctx, gf, 1)
231
232 assert np.allclose(numpy(tsum, allow_copy=True), a + b)
233
234class TestQuantization:
235

Callers

nothing calls this directly

Calls 3

copyFunction · 0.90
numpyFunction · 0.90
ggml_new_tensor_1dMethod · 0.80

Tested by

no test coverage detected