]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
examples : remove prompt pipe-in support
authorGeorgi Gerganov <redacted>
Wed, 24 May 2023 07:41:06 +0000 (10:41 +0300)
committerGeorgi Gerganov <redacted>
Wed, 24 May 2023 07:41:06 +0000 (10:41 +0300)
Need cross-platform solution, factored out in common

examples/dolly-v2/main.cpp
examples/gpt-2/main.cpp
examples/gpt-j/main.cpp
examples/gpt-neox/main.cpp
examples/mpt/main.cpp
examples/replit/main.cpp
examples/starcoder/main.cpp

index e36d6e0ea9ca9c9347566e5839563bd111622ad0..d2783e2aa893642dc0004d30be2edd5469394c97 100644 (file)
@@ -12,8 +12,6 @@
 #include <map>
 #include <string>
 #include <vector>
-#include <iostream>
-#include <unistd.h>
 
 // default hparams (Dolly-V2 3B)
 struct dollyv2_hparams {
@@ -689,14 +687,7 @@ int main(int argc, char ** argv) {
 
     std::mt19937 rng(params.seed);
     if (params.prompt.empty()) {
-        if( !isatty(STDIN_FILENO) ){
-            std::string line;
-            while( std::getline(std::cin, line) ){
-                params.prompt = params.prompt + "\n" + line;
-            }
-        } else {
-            params.prompt = gpt_random_prompt(rng);
-        }
+        params.prompt = gpt_random_prompt(rng);
     }
 
     const std::string prompt = prompt_for_generation(params.prompt);
index 5d22793464f6722a1b848aeb925079c001b684d4..47f5e5e4aeb240ea66040b91b26a875f93d8f6d2 100644 (file)
@@ -11,8 +11,6 @@
 #include <map>
 #include <string>
 #include <vector>
-#include <iostream>
-#include <unistd.h>
 
 // default hparams (GPT-2 117M)
 struct gpt2_hparams {
@@ -716,14 +714,7 @@ int main(int argc, char ** argv) {
 
     std::mt19937 rng(params.seed);
     if (params.prompt.empty()) {
-        if( !isatty(STDIN_FILENO) ){
-            std::string line;
-            while( std::getline(std::cin, line) ){
-                params.prompt = params.prompt + "\n" + line;
-            }
-        } else {
-            params.prompt = gpt_random_prompt(rng);
-        }
+        params.prompt = gpt_random_prompt(rng);
     }
 
     int64_t t_load_us = 0;
index 8fd9362ff5134647135b1300049e2277016e6c69..ee6d1a991b1529002603498231b1009983990077 100644 (file)
@@ -11,8 +11,6 @@
 #include <map>
 #include <string>
 #include <vector>
-#include <iostream>
-#include <unistd.h>
 
 // default hparams (GPT-J 6B)
 struct gptj_hparams {
@@ -625,14 +623,7 @@ int main(int argc, char ** argv) {
 
     std::mt19937 rng(params.seed);
     if (params.prompt.empty()) {
-        if( !isatty(STDIN_FILENO) ){
-            std::string line;
-            while( std::getline(std::cin, line) ){
-                params.prompt = params.prompt + "\n" + line;
-            }
-        } else {
-            params.prompt = gpt_random_prompt(rng);
-        }
+        params.prompt = gpt_random_prompt(rng);
     }
 
     int64_t t_load_us = 0;
index 183585d5901d047074317eceffd590cb8bd10566..c5a73232aadc52b8e320583f51dc006cca926bd3 100644 (file)
@@ -12,8 +12,6 @@
 #include <map>
 #include <string>
 #include <vector>
-#include <iostream>
-#include <unistd.h>
 
 // default hparams (StableLM 3B)
 struct gpt_neox_hparams {
@@ -688,14 +686,7 @@ int main(int argc, char ** argv) {
 
     std::mt19937 rng(params.seed);
     if (params.prompt.empty()) {
-        if( !isatty(STDIN_FILENO) ){
-            std::string line;
-            while( std::getline(std::cin, line) ){
-                params.prompt = params.prompt + "\n" + line;
-            }
-        } else {
-            params.prompt = gpt_random_prompt(rng);
-        }
+        params.prompt = gpt_random_prompt(rng);
     }
 
     int64_t t_load_us = 0;
index 2890884cd702e1e6cfe483b5019a12025699e3c4..74235aa3c44809ce35e2e9d3afbf73be397c6a77 100644 (file)
@@ -3,18 +3,13 @@
 #include "common-ggml.h"
 #include "common.h"
 
-#include <cassert>
 #include <cmath>
 #include <cstddef>
 #include <cstdio>
-#include <cstring>
 #include <fstream>
-#include <iostream>
+#include <cinttypes>
 #include <map>
-#include <stdint.h>
 #include <string>
-#include <unistd.h>
-#include <unordered_map>
 #include <utility>
 #include <vector>
 
@@ -352,7 +347,7 @@ bool mpt_model_load(const std::string & fname, mpt_model & model, gpt_vocab & vo
 
         const size_t memory_size = ggml_nbytes(model.memory_k) + ggml_nbytes(model.memory_v);
 
-        printf("%s: memory_size = %8.2f MB, n_mem = %ld\n", __func__, memory_size / 1024.0 / 1024.0, n_mem);
+        printf("%s: memory_size = %8.2f MB, n_mem = %" PRId64 "\n", __func__, memory_size / 1024.0 / 1024.0, n_mem);
     }
 
     // load weights
@@ -878,14 +873,7 @@ int main(int argc, char ** argv) {
 
     std::mt19937 rng(params.seed);
     if (params.prompt.empty()) {
-        if (!isatty(STDIN_FILENO)) {
-            std::string line;
-            while (std::getline(std::cin, line)) {
-                params.prompt = params.prompt + "\n" + line;
-            }
-        } else {
-            params.prompt = gpt_random_prompt(rng);
-        }
+        params.prompt = gpt_random_prompt(rng);
     }
 
     int64_t t_load_us = 0;
index cd678a494b909fadf6ec492d3ba79b93454c9465..05a80112ffa6a0e61a54de8565b09e48de7668ac 100644 (file)
@@ -9,11 +9,9 @@
 #include <cstdio>
 #include <cstring>
 #include <fstream>
-#include <iostream>
 #include <map>
 #include <stdint.h>
 #include <string>
-#include <unistd.h>
 #include <unordered_map>
 #include <utility>
 #include <vector>
@@ -643,14 +641,7 @@ int main(int argc, char ** argv) {
 
     std::mt19937 rng(params.seed);
     if (params.prompt.empty()) {
-        if (!isatty(STDIN_FILENO)) {
-            std::string line;
-            while (std::getline(std::cin, line)) {
-                params.prompt = params.prompt + "\n" + line;
-            }
-        } else {
-            params.prompt = gpt_random_prompt(rng);
-        }
+        params.prompt = gpt_random_prompt(rng);
     }
 
     int64_t t_load_us = 0;
index c9d1d7ec7d55527e550e9c72b7d54d91d55ebec9..2a6be4eab789748d34665b28713cf863ac75b6ed 100644 (file)
@@ -11,8 +11,6 @@
 #include <map>
 #include <string>
 #include <vector>
-#include <iostream>
-#include <unistd.h>
 
 // default hparams (GPT-2 117M)
 // https://huggingface.co/bigcode/gpt_bigcode-santacoder/blob/main/config.json
@@ -742,14 +740,7 @@ int main(int argc, char ** argv) {
 
     std::mt19937 rng(params.seed);
     if (params.prompt.empty()) {
-        if( !isatty(STDIN_FILENO) ){
-            std::string line;
-            while( std::getline(std::cin, line) ){
-                params.prompt = params.prompt + "\n" + line;
-            }
-        } else {
-            params.prompt = gpt_random_prompt(rng);
-        }
+        params.prompt = gpt_random_prompt(rng);
     }
 
     int64_t t_load_us = 0;