Skip to content
6 changes: 4 additions & 2 deletions examples/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <cstdio>
#include <string>
#include <thread>
#include <utility>
#include <vector>
#include <cstring>

Expand Down Expand Up @@ -1019,10 +1018,12 @@ int main(int argc, char ** argv) {

bool open(const char * ext, const char * function) {
if (is_stdout) {
if (std::exchange(used_stdout, true)) {
if (used_stdout) {
fprintf(stderr, "warning: Not appending multiple file formats to stdout\n");
return false;
}

used_stdout = true;
#ifdef _WIN32
fout = std::ofstream{"CON"};
#else
Expand All @@ -1032,6 +1033,7 @@ int main(int argc, char ** argv) {
// Also assuming /dev is mounted
return true;
}

fname_out.resize(basename_length);
fname_out += ext;
fout = std::ofstream{fname_out};
Expand Down
5 changes: 4 additions & 1 deletion ggml/src/ggml-alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,10 @@ static void ggml_gallocr_init_tensor(ggml_gallocr_t galloc, struct ggml_tensor *
static bool ggml_gallocr_node_needs_realloc(ggml_gallocr_t galloc, struct ggml_tensor * node, struct tensor_alloc * talloc) {
size_t node_size = 0;
if (!node->data && !node->view_src) {
GGML_ASSERT(talloc->buffer_id >= 0); // prevent segfault when misusing the API
// If we previously had data but don't now then reallocate
if (talloc->buffer_id < 0) {
return false;
}
node_size = ggml_backend_buft_get_alloc_size(galloc->bufts[talloc->buffer_id], node);
}
return talloc->size_max >= node_size;
Expand Down
Loading
Loading