Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions examples/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
#include "common.h"

#include <cmath>
#include <codecvt>
#include <cstring>
#include <fstream>
#include <locale>
#include <regex>
#include <sstream>

Expand Down
9 changes: 6 additions & 3 deletions examples/stb_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -5079,8 +5079,8 @@ static void stbi__de_iphone(stbi__png *z)
static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
{
stbi_uc palette[1024], pal_img_n=0;
stbi_uc has_trans=0, tc[3]={0};
stbi__uint16 tc16[3];
stbi_uc has_trans=0, tc[4]={0};
stbi__uint16 tc16[4];
stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0;
int first=1,k,interlace=0, color=0, is_iphone=0;
stbi__context *s = z->s;
Expand Down Expand Up @@ -5163,7 +5163,10 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
if (z->depth == 16) {
for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
} else {
for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
for (k = 0; k < s->img_n; ++k) {
stbi_uc value = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth];
if (k < 4) tc[k] = value;
} // non 8-bit images will be larger
}
}
break;
Expand Down
25 changes: 8 additions & 17 deletions src/ggml-backend-reg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@
#include "ggml-cann.h"
#endif

// disable C++17 deprecation warning for std::codecvt_utf8
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

namespace fs = std::filesystem;

static std::string path_str(const fs::path & path) {
Expand Down Expand Up @@ -498,36 +489,36 @@ static fs::path get_executable_path() {

static fs::path backend_filename_prefix() {
#ifdef _WIN32
return fs::u8path("ggml-");
return fs::path("ggml-");
#else
return fs::u8path("libggml-");
return fs::path("libggml-");
#endif
}

static fs::path backend_filename_extension() {
#ifdef _WIN32
return fs::u8path(".dll");
return fs::path(".dll");
#else
return fs::u8path(".so");
return fs::path(".so");
#endif
}

static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent, const char * user_search_path) {
// enumerate all the files that match [lib]ggml-name-*.[so|dll] in the search paths
const fs::path name_path = fs::u8path(name);
const fs::path file_prefix = backend_filename_prefix().native() + name_path.native() + fs::u8path("-").native();
const fs::path name_path = fs::path(name);
const fs::path file_prefix = backend_filename_prefix().native() + name_path.native() + fs::path("-").native();
const fs::path file_extension = backend_filename_extension();

std::vector<fs::path> search_paths;
if (user_search_path == nullptr) {
#ifdef GGML_BACKEND_DIR
search_paths.push_back(fs::u8path(GGML_BACKEND_DIR));
search_paths.push_back(fs::path(GGML_BACKEND_DIR));
#endif
// default search paths: executable directory, current directory
search_paths.push_back(get_executable_path());
search_paths.push_back(fs::current_path());
} else {
search_paths.push_back(fs::u8path(user_search_path));
search_paths.push_back(fs::path(user_search_path));
}

int best_score = 0;
Expand Down
6 changes: 3 additions & 3 deletions tests/test-backend-ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7521,9 +7521,9 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
test_cases.emplace_back(new test_interpolate(GGML_TYPE_F32, {5, 7, 11, 13}, {2, 5, 7, 11}, mode));
}
for (ggml_scale_mode mode : {GGML_SCALE_MODE_BILINEAR, GGML_SCALE_MODE_BICUBIC}) {
test_cases.emplace_back(new test_interpolate(GGML_TYPE_F32, {2, 5, 7, 11}, {5, 7, 11, 13}, mode | GGML_SCALE_FLAG_ALIGN_CORNERS));
test_cases.emplace_back(new test_interpolate(GGML_TYPE_F32, {1, 4, 3, 2}, {2, 8, 3, 2}, mode | GGML_SCALE_FLAG_ALIGN_CORNERS));
test_cases.emplace_back(new test_interpolate(GGML_TYPE_F32, {4, 1, 3, 2}, {1, 1, 3, 2}, mode | GGML_SCALE_FLAG_ALIGN_CORNERS));
test_cases.emplace_back(new test_interpolate(GGML_TYPE_F32, {2, 5, 7, 11}, {5, 7, 11, 13}, static_cast<uint32_t>(mode) | GGML_SCALE_FLAG_ALIGN_CORNERS));
test_cases.emplace_back(new test_interpolate(GGML_TYPE_F32, {1, 4, 3, 2}, {2, 8, 3, 2}, static_cast<uint32_t>(mode) | GGML_SCALE_FLAG_ALIGN_CORNERS));
test_cases.emplace_back(new test_interpolate(GGML_TYPE_F32, {4, 1, 3, 2}, {1, 1, 3, 2}, static_cast<uint32_t>(mode) | GGML_SCALE_FLAG_ALIGN_CORNERS));
}

test_cases.emplace_back(new test_sum());
Expand Down
6 changes: 3 additions & 3 deletions tests/test-interpolate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ int main() {
passed &= test_interpolate("upscale_x2_bilinear_align_corners",
{2, 2, 1, 1}, input_upscale,
{4, 4, 1, 1}, expected_upscale_x2_bilinear_align_corners,
GGML_SCALE_MODE_BILINEAR | GGML_SCALE_FLAG_ALIGN_CORNERS);
static_cast<uint32_t>(GGML_SCALE_MODE_BILINEAR) | GGML_SCALE_FLAG_ALIGN_CORNERS);

passed &= test_interpolate("upscale_x1_5_bilinear_align_corners",
{2, 2, 1, 1}, input_upscale,
{2, 3, 1, 1}, expected_upscale_x1_5_bilinear_align_corners,
GGML_SCALE_MODE_BILINEAR | GGML_SCALE_FLAG_ALIGN_CORNERS);
static_cast<uint32_t>(GGML_SCALE_MODE_BILINEAR) | GGML_SCALE_FLAG_ALIGN_CORNERS);

passed &= test_interpolate("downscale_nearest",
{4, 3, 2, 1}, input_downscale,
Expand All @@ -160,7 +160,7 @@ int main() {
passed &= test_interpolate("downscale_bilinear_align_corners",
{4, 3, 2, 1}, input_downscale,
{3, 2, 2, 1}, expected_downscale_bilinear_align_corners,
GGML_SCALE_MODE_BILINEAR | GGML_SCALE_FLAG_ALIGN_CORNERS);
static_cast<uint32_t>(GGML_SCALE_MODE_BILINEAR) | GGML_SCALE_FLAG_ALIGN_CORNERS);

return passed ? 0 : 1;
}