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

Function load_model

external/ggml/tests/test-conv-transpose-1d.cpp:52–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50};
51
52void load_model(test_model & model, bool use_gpu = false) {
53
54
55 float adata_0[] = {1,2,3};
56 float bdata_0[] = {1,2};
57
58 float adata_1[] = {1,2,3,3,2,1};
59 float bdata_1[] = {2,3,1,1,3,2};
60
61 float adata_2[] = {3,2,1,1,2,3,1,2,3,3,2,1};
62 float bdata_2[] = {2,3,1,1,3,2};
63
64 float data[16*32*32];
65 for (int i = 0; i < 16*32*32; ++i) {
66 data[i] = (float)(i%1024);
67 }
68
69
70
71
72 size_t buffer_size = 0;
73 {
74 buffer_size += 3* ggml_type_size(GGML_TYPE_F32); // tensor a_0
75 buffer_size += 2* ggml_type_size(GGML_TYPE_F32); // tensor b_0
76
77 buffer_size += 6* ggml_type_size(GGML_TYPE_F32); // tensor a_1
78 buffer_size += 6* ggml_type_size(GGML_TYPE_F32); // tensor b_1
79
80 buffer_size += 12* ggml_type_size(GGML_TYPE_F32); // tensor a_2
81 buffer_size += 6* ggml_type_size(GGML_TYPE_F32); // tensor b_2
82
83 buffer_size += 2 * 3 * 2 * ggml_type_size(GGML_TYPE_F32); // tensor a_3
84 buffer_size += 3 * 2* ggml_type_size(GGML_TYPE_F32); // tensor b_3
85
86 buffer_size += 16 * 32 * 32 * ggml_type_size(GGML_TYPE_F32); // tensor a_4
87 buffer_size += 197 * 32* ggml_type_size(GGML_TYPE_F32); // tensor b_4
88
89 buffer_size += 1024;
90 }
91
92 printf("%s: ggml tensor size = %d bytes\n", __func__, (int) sizeof(ggml_tensor));
93 printf("%s: backend buffer size = %0.2f MB\n", __func__, (buffer_size/ 1024.f/ 1024.f));
94
95 int num_tensors = 10;
96 struct ggml_init_params params {
97 /*.mem_size =*/ ggml_tensor_overhead() * num_tensors,
98 /*.mem_buffer =*/ NULL,
99 /*.no_alloc =*/ true,
100 };
101
102 ggml_log_set(ggml_log_callback_default, nullptr);
103
104 // initialize the backend
105#ifdef GGML_USE_CUDA
106 if (use_gpu) {
107 fprintf(stderr, "%s: using CUDA backend\n", __func__);
108 model.backend = ggml_backend_cuda_init(0);
109 if (!model.backend) {

Callers 1

mainFunction · 0.70

Calls 15

ggml_type_sizeFunction · 0.85
ggml_tensor_overheadFunction · 0.85
ggml_log_setFunction · 0.85
ggml_backend_metal_initFunction · 0.85
ggml_backend_cpu_initFunction · 0.85
ggml_initFunction · 0.85
ggml_new_tensor_1dFunction · 0.85
ggml_new_tensor_3dFunction · 0.85
ggml_new_tensor_2dFunction · 0.85
ggml_tallocr_newFunction · 0.85
ggml_tallocr_allocFunction · 0.85

Tested by

no test coverage detected