Merge branch 'ggerganov:master' into master

pull/87/head
wizd 2 years ago committed by GitHub
commit 7438b83939
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -218,3 +218,18 @@ Note the use of `--color` to distinguish between user input and generated text.
know how to utilize it properly. But in any case, you can even disable it with `LLAMA_NO_ACCELERATE=1 make` and the know how to utilize it properly. But in any case, you can even disable it with `LLAMA_NO_ACCELERATE=1 make` and the
performance will be the same, since no BLAS calls are invoked by the current implementation performance will be the same, since no BLAS calls are invoked by the current implementation
### Contributing
- There are 2 git branches: [master](https://github.com/ggerganov/llama.cpp/commits/master) and [dev](https://github.com/ggerganov/llama.cpp/commits/dev)
- Contributors can open PRs to either one
- Collaborators can push straight into `dev`, but need to open a PR to get stuff to `master`
- Collaborators will be invited based on contributions
- `dev` branch is considered unstable
- `master` branch is considered stable and approved. 3-rd party projects should use the `master` branch
General principles to follow when writing code:
- Avoid adding third-party dependencies, extra files, extra headers, etc.
- Always consider cross-compatibility with other operating systems and architectures
- Avoid fancy looking modern STL constructs, use basic for loops, avoid templates, keep it simple
- There are no strict rules for the code style, but try to follow the patterns in the code (indentation, spaces, etc.). Vertical alignment makes things more readable and easier to batch edit

@ -17,8 +17,10 @@
#include <sstream> #include <sstream>
#include <regex> #include <regex>
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#endif
#define ANSI_COLOR_RED "\x1b[31m" #define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m" #define ANSI_COLOR_GREEN "\x1b[32m"
@ -756,6 +758,7 @@ bool llama_eval(
static bool is_interacting = false; static bool is_interacting = false;
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
void sigint_handler(int signo) { void sigint_handler(int signo) {
if (signo == SIGINT) { if (signo == SIGINT) {
if (!is_interacting) { if (!is_interacting) {
@ -765,6 +768,7 @@ void sigint_handler(int signo) {
} }
} }
} }
#endif
int main(int argc, char ** argv) { int main(int argc, char ** argv) {
ggml_time_init(); ggml_time_init();
@ -834,11 +838,13 @@ int main(int argc, char ** argv) {
} }
printf("\n"); printf("\n");
if (params.interactive) { if (params.interactive) {
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
struct sigaction sigint_action; struct sigaction sigint_action;
sigint_action.sa_handler = sigint_handler; sigint_action.sa_handler = sigint_handler;
sigemptyset (&sigint_action.sa_mask); sigemptyset (&sigint_action.sa_mask);
sigint_action.sa_flags = 0; sigint_action.sa_flags = 0;
sigaction(SIGINT, &sigint_action, NULL); sigaction(SIGINT, &sigint_action, NULL);
#endif
printf("%s: interactive mode on.\n", __func__); printf("%s: interactive mode on.\n", __func__);
@ -867,7 +873,9 @@ int main(int argc, char ** argv) {
if (params.interactive) { if (params.interactive) {
printf("== Running in interactive mode. ==\n" printf("== Running in interactive mode. ==\n"
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
" - Press Ctrl+C to interject at any time.\n" " - Press Ctrl+C to interject at any time.\n"
#endif
" - Press Return to return control to LLaMa.\n" " - Press Return to return control to LLaMa.\n"
" - If you want to submit another line, end your input in '\\'.\n"); " - If you want to submit another line, end your input in '\\'.\n");
} }
@ -970,10 +978,15 @@ int main(int argc, char ** argv) {
// currently being interactive // currently being interactive
bool another_line=true; bool another_line=true;
while (another_line) { while (another_line) {
fflush(stdout);
char buf[256] = {0}; char buf[256] = {0};
int n_read; int n_read;
if(params.use_color) printf(ANSI_BOLD ANSI_COLOR_GREEN); if(params.use_color) printf(ANSI_BOLD ANSI_COLOR_GREEN);
scanf("%255[^\n]%n%*c", buf, &n_read); if (scanf("%255[^\n]%n%*c", buf, &n_read) <= 0) {
// presumable empty line, consume the newline
scanf("%*c");
n_read=0;
}
if(params.use_color) printf(ANSI_COLOR_RESET); if(params.use_color) printf(ANSI_COLOR_RESET);
if (n_read > 0 && buf[n_read-1]=='\\') { if (n_read > 0 && buf[n_read-1]=='\\') {

Loading…
Cancel
Save