File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -3808,6 +3808,10 @@ enum ggml_type ggml_ftype_to_ggml_type(enum ggml_ftype ftype) {
3808
3808
return wtype ;
3809
3809
}
3810
3810
3811
+ size_t ggml_tensor_overhead (void ) {
3812
+ return GGML_OBJECT_SIZE + GGML_TENSOR_SIZE + 16 ;
3813
+ }
3814
+
3811
3815
static inline bool ggml_is_transposed (const struct ggml_tensor * tensor ) {
3812
3816
return tensor -> nb [0 ] > tensor -> nb [1 ];
3813
3817
}
@@ -14527,6 +14531,14 @@ void ggml_graph_reset(struct ggml_cgraph * cgraph) {
14527
14531
}
14528
14532
14529
14533
struct ggml_tensor * ggml_get_tensor_by_name (struct ggml_cgraph * cgraph , const char * name ) {
14534
+ for (int i = 0 ; i < cgraph -> n_leafs ; i ++ ) {
14535
+ struct ggml_tensor * leaf = cgraph -> leafs [i ];
14536
+
14537
+ if (strcmp (leaf -> name , name ) == 0 ) {
14538
+ return leaf ;
14539
+ }
14540
+ }
14541
+
14530
14542
for (int i = 0 ; i < cgraph -> n_nodes ; i ++ ) {
14531
14543
struct ggml_tensor * node = cgraph -> nodes [i ];
14532
14544
Original file line number Diff line number Diff line change @@ -380,9 +380,6 @@ extern "C" {
380
380
381
381
static const size_t GGML_TENSOR_SIZE = sizeof (struct ggml_tensor );
382
382
383
- // use this to compute the memory overhead of a tensor
384
- static const size_t GGML_TENSOR_OVERHEAD = (GGML_OBJECT_SIZE + GGML_TENSOR_SIZE + 16 );
385
-
386
383
// computation graph
387
384
struct ggml_cgraph {
388
385
int n_nodes ;
@@ -444,6 +441,9 @@ extern "C" {
444
441
// TODO: temporary until model loading of ggml examples is refactored
445
442
GGML_API enum ggml_type ggml_ftype_to_ggml_type (enum ggml_ftype ftype );
446
443
444
+ // use this to compute the memory overhead of a tensor
445
+ GGML_API size_t ggml_tensor_overhead (void );
446
+
447
447
// main
448
448
449
449
GGML_API struct ggml_context * ggml_init (struct ggml_init_params params );
You can’t perform that action at this time.
0 commit comments