From: Cebtenzzre Date: Sun, 23 Jul 2023 15:16:04 +0000 (-0400) Subject: ggml : build with -Wmissing-prototypes, fix warnings (#398) X-Git-Tag: upstream/0.0.1642~1298 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=07414d71878e43154528dc0f1e54df1f63631964;p=pkg%2Fggml%2Fsources%2Fggml ggml : build with -Wmissing-prototypes, fix warnings (#398) A few function declarations were missing from the API. This warning flag helps find these problems. --- diff --git a/include/ggml/ggml.h b/include/ggml/ggml.h index 871c85a8..d1539027 100644 --- a/include/ggml/ggml.h +++ b/include/ggml/ggml.h @@ -629,6 +629,11 @@ extern "C" { struct ggml_context * ctx, struct ggml_tensor * a); + // in-place, returns view(a) + GGML_API struct ggml_tensor * ggml_dup_inplace( + struct ggml_context * ctx, + struct ggml_tensor * a); + GGML_API struct ggml_tensor * ggml_add( struct ggml_context * ctx, struct ggml_tensor * a, @@ -952,11 +957,22 @@ extern "C" { struct ggml_tensor * a, struct ggml_tensor * b); + // a -> b, in-place, return view(b) + GGML_API struct ggml_tensor * ggml_cpy_inplace( + struct ggml_context * ctx, + struct ggml_tensor * a, + struct ggml_tensor * b); + // make contiguous GGML_API struct ggml_tensor * ggml_cont( struct ggml_context * ctx, struct ggml_tensor * a); + // make contiguous, in-place + GGML_API struct ggml_tensor * ggml_cont_inplace( + struct ggml_context * ctx, + struct ggml_tensor * a); + // return view(a), b specifies the new shape // TODO: when we start computing gradient, make a copy instead of view GGML_API struct ggml_tensor * ggml_reshape( diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eacc9862..9862a0d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,6 +11,7 @@ if (GGML_ALL_WARNINGS) -Wpointer-arith \ -Wdouble-promotion \ -Wno-unused-function \ + -Wmissing-prototypes \ ") else() # todo : windows diff --git a/src/ggml.c b/src/ggml.c index b1be7d8d..931a2092 100644 --- a/src/ggml.c +++ b/src/ggml.c @@ -4482,7 +4482,7 @@ size_t ggml_get_max_tensor_size(const struct ggml_context * ctx) { // this is an error prone process, but it is necessary to support inplace // operators when using scratch buffers // TODO: implement a better way -void ggml_scratch_save(struct ggml_context * ctx) { +static void ggml_scratch_save(struct ggml_context * ctx) { // this is needed to allow opt tensors to store their data // TODO: again, need to find a better way ctx->no_alloc_save = ctx->no_alloc; @@ -4492,7 +4492,7 @@ void ggml_scratch_save(struct ggml_context * ctx) { ctx->scratch.data = NULL; } -void ggml_scratch_load(struct ggml_context * ctx) { +static void ggml_scratch_load(struct ggml_context * ctx) { ctx->no_alloc = ctx->no_alloc_save; ctx->scratch = ctx->scratch_save; @@ -4500,7 +4500,7 @@ void ggml_scratch_load(struct ggml_context * ctx) { //////////////////////////////////////////////////////////////////////////////// -struct ggml_tensor * ggml_new_tensor_impl( +static struct ggml_tensor * ggml_new_tensor_impl( struct ggml_context * ctx, enum ggml_type type, int n_dims, @@ -5012,7 +5012,7 @@ struct ggml_tensor * ggml_get_tensor(struct ggml_context * ctx, const char * nam // ggml_dup -struct ggml_tensor * ggml_dup_impl( +static struct ggml_tensor * ggml_dup_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5045,7 +5045,7 @@ struct ggml_tensor * ggml_dup_inplace( // ggml_add -struct ggml_tensor * ggml_add_impl( +static struct ggml_tensor * ggml_add_impl( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -5088,7 +5088,7 @@ struct ggml_tensor * ggml_add_inplace( // ggml_add1 -struct ggml_tensor * ggml_add1_impl( +static struct ggml_tensor * ggml_add1_impl( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -5128,7 +5128,7 @@ struct ggml_tensor * ggml_add1_inplace( // ggml_acc -struct ggml_tensor * ggml_acc_impl( +static struct ggml_tensor * ggml_acc_impl( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -5185,7 +5185,7 @@ struct ggml_tensor * ggml_acc_inplace( // ggml_sub -struct ggml_tensor * ggml_sub_impl( +static struct ggml_tensor * ggml_sub_impl( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -5224,7 +5224,7 @@ struct ggml_tensor * ggml_sub_inplace( // ggml_mul -struct ggml_tensor * ggml_mul_impl( +static struct ggml_tensor * ggml_mul_impl( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -5271,7 +5271,7 @@ struct ggml_tensor * ggml_mul_inplace( // ggml_div -struct ggml_tensor * ggml_div_impl( +static struct ggml_tensor * ggml_div_impl( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -5314,7 +5314,7 @@ struct ggml_tensor * ggml_div_inplace( // ggml_sqr -struct ggml_tensor * ggml_sqr_impl( +static struct ggml_tensor * ggml_sqr_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5347,7 +5347,7 @@ struct ggml_tensor * ggml_sqr_inplace( // ggml_sqrt -struct ggml_tensor * ggml_sqrt_impl( +static struct ggml_tensor * ggml_sqrt_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5381,7 +5381,7 @@ struct ggml_tensor * ggml_sqrt_inplace( // ggml_log -struct ggml_tensor * ggml_log_impl( +static struct ggml_tensor * ggml_log_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5561,7 +5561,7 @@ struct ggml_tensor * ggml_repeat_back( // ggml_abs -struct ggml_tensor * ggml_abs_impl( +static struct ggml_tensor * ggml_abs_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5595,7 +5595,7 @@ struct ggml_tensor * ggml_abs_inplace( // ggml_sgn -struct ggml_tensor * ggml_sgn_impl( +static struct ggml_tensor * ggml_sgn_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5628,7 +5628,7 @@ struct ggml_tensor * ggml_sgn_inplace( // ggml_neg -struct ggml_tensor * ggml_neg_impl( +static struct ggml_tensor * ggml_neg_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5661,7 +5661,7 @@ struct ggml_tensor * ggml_neg_inplace( // ggml_step -struct ggml_tensor * ggml_step_impl( +static struct ggml_tensor * ggml_step_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5694,7 +5694,7 @@ struct ggml_tensor * ggml_step_inplace( // ggml_tanh -struct ggml_tensor * ggml_tanh_impl( +static struct ggml_tensor * ggml_tanh_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5727,7 +5727,7 @@ struct ggml_tensor * ggml_tanh_inplace( // ggml_elu -struct ggml_tensor * ggml_elu_impl( +static struct ggml_tensor * ggml_elu_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5760,7 +5760,7 @@ struct ggml_tensor * ggml_elu_inplace( // ggml_relu -struct ggml_tensor * ggml_relu_impl( +static struct ggml_tensor * ggml_relu_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5793,7 +5793,7 @@ struct ggml_tensor * ggml_relu_inplace( // ggml_gelu -struct ggml_tensor * ggml_gelu_impl( +static struct ggml_tensor * ggml_gelu_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5826,7 +5826,7 @@ struct ggml_tensor * ggml_gelu_inplace( // ggml_gelu_quick -struct ggml_tensor * ggml_gelu_quick_impl( +static struct ggml_tensor * ggml_gelu_quick_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5859,7 +5859,7 @@ struct ggml_tensor * ggml_gelu_quick_inplace( // ggml_silu -struct ggml_tensor * ggml_silu_impl( +static struct ggml_tensor * ggml_silu_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5915,7 +5915,7 @@ struct ggml_tensor * ggml_silu_back( // ggml_norm -struct ggml_tensor * ggml_norm_impl( +static struct ggml_tensor * ggml_norm_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -5949,7 +5949,7 @@ struct ggml_tensor * ggml_norm_inplace( return ggml_norm_impl(ctx, a, true); } -struct ggml_tensor * ggml_rms_norm_impl( +static struct ggml_tensor * ggml_rms_norm_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -6058,7 +6058,7 @@ struct ggml_tensor * ggml_out_prod( // ggml_scale -struct ggml_tensor * ggml_scale_impl( +static struct ggml_tensor * ggml_scale_impl( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -6098,7 +6098,7 @@ struct ggml_tensor * ggml_scale_inplace( // ggml_set -struct ggml_tensor * ggml_set_impl( +static struct ggml_tensor * ggml_set_impl( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -6188,7 +6188,7 @@ struct ggml_tensor * ggml_set_2d_inplace( // ggml_cpy -struct ggml_tensor * ggml_cpy_impl( +static struct ggml_tensor * ggml_cpy_impl( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -6233,7 +6233,7 @@ struct ggml_tensor * ggml_cpy_inplace( // ggml_cont -struct ggml_tensor * ggml_cont_impl( +static struct ggml_tensor * ggml_cont_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -6703,7 +6703,7 @@ struct ggml_tensor * ggml_diag( // ggml_diag_mask_inf -struct ggml_tensor * ggml_diag_mask_inf_impl( +static struct ggml_tensor * ggml_diag_mask_inf_impl( struct ggml_context * ctx, struct ggml_tensor * a, int n_past, @@ -6743,7 +6743,7 @@ struct ggml_tensor * ggml_diag_mask_inf_inplace( // ggml_diag_mask_zero -struct ggml_tensor * ggml_diag_mask_zero_impl( +static struct ggml_tensor * ggml_diag_mask_zero_impl( struct ggml_context * ctx, struct ggml_tensor * a, int n_past, @@ -6782,7 +6782,7 @@ struct ggml_tensor * ggml_diag_mask_zero_inplace( // ggml_soft_max -struct ggml_tensor * ggml_soft_max_impl( +static struct ggml_tensor * ggml_soft_max_impl( struct ggml_context * ctx, struct ggml_tensor * a, bool inplace) { @@ -6816,7 +6816,7 @@ struct ggml_tensor * ggml_soft_max_inplace( // ggml_soft_max_back -struct ggml_tensor * ggml_soft_max_back_impl( +static struct ggml_tensor * ggml_soft_max_back_impl( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -6853,7 +6853,7 @@ struct ggml_tensor * ggml_soft_max_back_inplace( // ggml_rope -struct ggml_tensor * ggml_rope_impl( +static struct ggml_tensor * ggml_rope_impl( struct ggml_context * ctx, struct ggml_tensor * a, int n_past, @@ -7367,7 +7367,7 @@ struct ggml_tensor * ggml_win_unpart( // ggml_map_unary -struct ggml_tensor * ggml_map_unary_impl_f32( +static struct ggml_tensor * ggml_map_unary_impl_f32( struct ggml_context * ctx, struct ggml_tensor * a, const ggml_unary_op_f32_t fun, @@ -7405,7 +7405,7 @@ struct ggml_tensor * ggml_map_unary_inplace_f32( // ggml_map_binary -struct ggml_tensor * ggml_map_binary_impl_f32( +static struct ggml_tensor * ggml_map_binary_impl_f32( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -7449,7 +7449,7 @@ struct ggml_tensor * ggml_map_binary_inplace_f32( // ggml_map_custom1 -struct ggml_tensor * ggml_map_custom1_impl_f32( +static struct ggml_tensor * ggml_map_custom1_impl_f32( struct ggml_context * ctx, struct ggml_tensor * a, const ggml_custom1_op_f32_t fun, @@ -7487,7 +7487,7 @@ struct ggml_tensor * ggml_map_custom1_inplace_f32( // ggml_map_custom2 -struct ggml_tensor * ggml_map_custom2_impl_f32( +static struct ggml_tensor * ggml_map_custom2_impl_f32( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -7529,7 +7529,7 @@ struct ggml_tensor * ggml_map_custom2_inplace_f32( // ggml_map_custom3 -struct ggml_tensor * ggml_map_custom3_impl_f32( +static struct ggml_tensor * ggml_map_custom3_impl_f32( struct ggml_context * ctx, struct ggml_tensor * a, struct ggml_tensor * b, @@ -15927,7 +15927,7 @@ typedef pthread_t ggml_thread_t; // Android's libc implementation "bionic" does not support setting affinity #if defined(__linux__) && !defined(__BIONIC__) -void set_numa_thread_affinity(int thread_n, int n_threads) { +static void set_numa_thread_affinity(int thread_n, int n_threads) { if (!ggml_is_numa()) { return; } @@ -15952,7 +15952,7 @@ void set_numa_thread_affinity(int thread_n, int n_threads) { CPU_FREE(cpus); } -void clear_numa_thread_affinity(void) { +static void clear_numa_thread_affinity(void) { if (!ggml_is_numa()) { return; }