Skip to content

Commit 452e21d

Browse files
tamarPaltamarPal
authored andcommitted
fix: remove trailing whitespace
1 parent 805c1bb commit 452e21d

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

tools/quantize/quantize.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ static const char * const LLM_KV_IMATRIX_CHUNK_SIZE = "imatrix.chunk_size";
9090
// Returns true if they are the same file (including via hardlinks or symlinks)
9191
static bool same_file(const std::string & path_a, const std::string & path_b) {
9292
std::error_code ec_a, ec_b;
93-
93+
9494
// First try using std::filesystem to resolve canonical paths
9595
auto canonical_a = std::filesystem::weakly_canonical(path_a, ec_a);
9696
auto canonical_b = std::filesystem::weakly_canonical(path_b, ec_b);
97-
97+
9898
if (!ec_a && !ec_b) {
9999
// If both paths were successfully canonicalized, compare them
100100
if (canonical_a == canonical_b) {
101101
return true;
102102
}
103103
}
104-
104+
105105
#ifndef _WIN32
106106
// On Unix-like systems, also check using stat() to handle hardlinks
107107
struct stat stat_a, stat_b;
@@ -112,7 +112,7 @@ static bool same_file(const std::string & path_a, const std::string & path_b) {
112112
}
113113
}
114114
#endif
115-
115+
116116
return false;
117117
}
118118

@@ -728,24 +728,24 @@ int main(int argc, char ** argv) {
728728
std::string fname_out_actual = fname_out;
729729
std::string fname_out_temp;
730730
bool use_temp_file = allow_inplace && same_file(fname_inp, fname_out);
731-
731+
732732
if (use_temp_file || allow_overwrite) {
733733
// Create temp file in the same directory as output for atomic rename
734734
std::filesystem::path out_path(fname_out);
735735
std::filesystem::path out_dir = out_path.parent_path();
736736
if (out_dir.empty()) {
737737
out_dir = ".";
738738
}
739-
739+
740740
// Generate temp filename
741741
fname_out_temp = (out_dir / ("." + out_path.filename().string() + ".tmp.XXXXXX")).string();
742-
742+
743743
// Create the temp file safely
744744
// Note: mkstemp would be safer but requires char* and creates the file
745745
// For simplicity, we'll use a simpler approach with PID
746746
fname_out_temp = (out_dir / ("." + out_path.filename().string() + ".tmp." + std::to_string(getpid()))).string();
747747
fname_out_actual = fname_out_temp;
748-
748+
749749
fprintf(stderr, "%s: using temporary file: '%s'\n", __func__, fname_out_actual.c_str());
750750
}
751751

@@ -765,35 +765,35 @@ int main(int argc, char ** argv) {
765765

766766
if (llama_model_quantize(fname_inp.c_str(), fname_out_actual.c_str(), &params)) {
767767
fprintf(stderr, "%s: failed to quantize model from '%s'\n", __func__, fname_inp.c_str());
768-
768+
769769
// Clean up temp file on failure
770770
if (!fname_out_temp.empty()) {
771771
std::error_code ec;
772772
std::filesystem::remove(fname_out_temp, ec);
773773
}
774-
774+
775775
llama_backend_free();
776776
return 1;
777777
}
778778

779779
t_quantize_us = llama_time_us() - t_start_us;
780780
}
781-
781+
782782
// If we used a temp file, atomically rename it to the final output
783783
if (!fname_out_temp.empty()) {
784784
fprintf(stderr, "%s: atomically moving temp file to final output\n", __func__);
785785
std::error_code ec;
786-
786+
787787
// On POSIX systems, rename() is atomic when both paths are on the same filesystem
788788
std::filesystem::rename(fname_out_temp, fname_out, ec);
789-
789+
790790
if (ec) {
791-
fprintf(stderr, "%s: failed to rename temp file '%s' to '%s': %s\n",
791+
fprintf(stderr, "%s: failed to rename temp file '%s' to '%s': %s\n",
792792
__func__, fname_out_temp.c_str(), fname_out.c_str(), ec.message().c_str());
793-
793+
794794
// Try to clean up temp file
795795
std::filesystem::remove(fname_out_temp, ec);
796-
796+
797797
llama_backend_free();
798798
return 1;
799799
}

0 commit comments

Comments
 (0)