fix most gcc and clang warnings
This commit is contained in:
parent
44c117f41e
commit
b44138c87d
6 changed files with 20 additions and 14 deletions
|
@ -402,6 +402,7 @@ if (LLAMA_ALL_WARNINGS)
|
||||||
-Wstrict-prototypes
|
-Wstrict-prototypes
|
||||||
-Wpointer-arith
|
-Wpointer-arith
|
||||||
-Wmissing-prototypes
|
-Wmissing-prototypes
|
||||||
|
-Wno-unused-function
|
||||||
)
|
)
|
||||||
set(cxx_flags
|
set(cxx_flags
|
||||||
-Wall
|
-Wall
|
||||||
|
@ -411,6 +412,10 @@ if (LLAMA_ALL_WARNINGS)
|
||||||
-Wno-unused-function
|
-Wno-unused-function
|
||||||
-Wno-multichar
|
-Wno-multichar
|
||||||
)
|
)
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
# g++ only
|
||||||
|
set(cxx_flags ${cxx_flags} -Wno-format-truncation)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
# todo : msvc
|
# todo : msvc
|
||||||
endif()
|
endif()
|
||||||
|
|
7
Makefile
7
Makefile
|
@ -64,9 +64,14 @@ endif
|
||||||
|
|
||||||
# warnings
|
# warnings
|
||||||
CFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith \
|
CFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith \
|
||||||
-Wmissing-prototypes
|
-Wmissing-prototypes -Wno-unused-function
|
||||||
CXXFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar
|
CXXFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar
|
||||||
|
|
||||||
|
ifeq '' '$(findstring clang++,$(CXX))'
|
||||||
|
# g++ only
|
||||||
|
CXXFLAGS += -Wno-format-truncation
|
||||||
|
endif
|
||||||
|
|
||||||
# OS specific
|
# OS specific
|
||||||
# TODO: support Windows
|
# TODO: support Windows
|
||||||
ifeq ($(UNAME_S),Linux)
|
ifeq ($(UNAME_S),Linux)
|
||||||
|
|
|
@ -1617,13 +1617,13 @@ int main(int argc, char ** argv) {
|
||||||
|
|
||||||
float error_before_opt = ggml_get_f32_1d(e, 0);
|
float error_before_opt = ggml_get_f32_1d(e, 0);
|
||||||
|
|
||||||
struct ggml_opt_params opt_params_adam = ggml_opt_default_params(GGML_OPT_ADAM);
|
// struct ggml_opt_params opt_params_adam = ggml_opt_default_params(GGML_OPT_ADAM);
|
||||||
struct ggml_opt_params opt_params_lbfgs = ggml_opt_default_params(GGML_OPT_LBFGS);
|
struct ggml_opt_params opt_params_lbfgs = ggml_opt_default_params(GGML_OPT_LBFGS);
|
||||||
opt_params_adam.print_forward_graph = false;
|
// opt_params_adam.print_forward_graph = false;
|
||||||
opt_params_adam.print_backward_graph = false;
|
// opt_params_adam.print_backward_graph = false;
|
||||||
opt_params_lbfgs.print_forward_graph = false;
|
opt_params_lbfgs.print_forward_graph = false;
|
||||||
opt_params_lbfgs.print_backward_graph = false;
|
opt_params_lbfgs.print_backward_graph = false;
|
||||||
opt_params_adam.adam.n_iter = 16;
|
// opt_params_adam.adam.n_iter = 16;
|
||||||
opt_params_lbfgs.lbfgs.n_iter = 16;
|
opt_params_lbfgs.lbfgs.n_iter = 16;
|
||||||
// ggml_opt(ctx0, opt_params_adam, e);
|
// ggml_opt(ctx0, opt_params_adam, e);
|
||||||
ggml_opt(ctx0, opt_params_lbfgs, e);
|
ggml_opt(ctx0, opt_params_lbfgs, e);
|
||||||
|
|
|
@ -1548,7 +1548,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
svr.set_exception_handler([](const Request &, Response &res, std::exception_ptr ep)
|
svr.set_exception_handler([](const Request &, Response &res, std::exception_ptr ep)
|
||||||
{
|
{
|
||||||
const auto * fmt = "500 Internal Server Error\n%s";
|
const char fmt[] = "500 Internal Server Error\n%s";
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
try {
|
try {
|
||||||
std::rethrow_exception(std::move(ep));
|
std::rethrow_exception(std::move(ep));
|
||||||
|
|
|
@ -183,13 +183,9 @@ static float make_qkx1_quants(int n, int nmax, const float * restrict x, uint8_t
|
||||||
int ntry, float alpha) {
|
int ntry, float alpha) {
|
||||||
float min = x[0];
|
float min = x[0];
|
||||||
float max = x[0];
|
float max = x[0];
|
||||||
float sum_x = 0;
|
|
||||||
float sum_x2 = 0;
|
|
||||||
for (int i = 1; i < n; ++i) {
|
for (int i = 1; i < n; ++i) {
|
||||||
if (x[i] < min) min = x[i];
|
if (x[i] < min) min = x[i];
|
||||||
if (x[i] > max) max = x[i];
|
if (x[i] > max) max = x[i];
|
||||||
sum_x += x[i];
|
|
||||||
sum_x2 += x[i]*x[i];
|
|
||||||
}
|
}
|
||||||
if (max == min) {
|
if (max == min) {
|
||||||
for (int i = 0; i < n; ++i) L[i] = 0;
|
for (int i = 0; i < n; ++i) L[i] = 0;
|
||||||
|
@ -2060,7 +2056,7 @@ void ggml_vec_dot_q3_K_q8_K(const int n, float * restrict s, const void * restri
|
||||||
|
|
||||||
__m256 acc = _mm256_setzero_ps();
|
__m256 acc = _mm256_setzero_ps();
|
||||||
|
|
||||||
uint32_t *aux;
|
const uint32_t *aux;
|
||||||
|
|
||||||
for (int i = 0; i < nb; ++i) {
|
for (int i = 0; i < nb; ++i) {
|
||||||
|
|
||||||
|
@ -2070,7 +2066,7 @@ void ggml_vec_dot_q3_K_q8_K(const int n, float * restrict s, const void * restri
|
||||||
const int8_t * restrict q8 = y[i].qs;
|
const int8_t * restrict q8 = y[i].qs;
|
||||||
|
|
||||||
// Set up scales
|
// Set up scales
|
||||||
aux = (uint32_t *)x[i].scales;
|
aux = (const uint32_t *)x[i].scales;
|
||||||
__m128i scales128 = _mm_set_epi32(
|
__m128i scales128 = _mm_set_epi32(
|
||||||
((aux[1] >> 4) & kmask2) | (((aux[2] >> 6) & kmask1) << 4),
|
((aux[1] >> 4) & kmask2) | (((aux[2] >> 6) & kmask1) << 4),
|
||||||
((aux[0] >> 4) & kmask2) | (((aux[2] >> 4) & kmask1) << 4),
|
((aux[0] >> 4) & kmask2) | (((aux[2] >> 4) & kmask1) << 4),
|
||||||
|
|
|
@ -3596,7 +3596,7 @@ static void llama_grammar_advance_stack(
|
||||||
std::vector<std::vector<const llama_grammar_element *>> & new_stacks) {
|
std::vector<std::vector<const llama_grammar_element *>> & new_stacks) {
|
||||||
|
|
||||||
if (stack.empty()) {
|
if (stack.empty()) {
|
||||||
new_stacks.push_back(stack);
|
new_stacks.emplace_back(stack);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3633,7 +3633,7 @@ static void llama_grammar_advance_stack(
|
||||||
}
|
}
|
||||||
case LLAMA_GRETYPE_CHAR:
|
case LLAMA_GRETYPE_CHAR:
|
||||||
case LLAMA_GRETYPE_CHAR_NOT:
|
case LLAMA_GRETYPE_CHAR_NOT:
|
||||||
new_stacks.push_back(stack);
|
new_stacks.emplace_back(stack);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// end of alternate (LLAMA_GRETYPE_END, LLAMA_GRETYPE_ALT) or middle of char range
|
// end of alternate (LLAMA_GRETYPE_END, LLAMA_GRETYPE_ALT) or middle of char range
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue