From 40564464b5a8b49a9648c6b35ccbc2c9c1019232 Mon Sep 17 00:00:00 2001 From: Coenraad Date: Mon, 22 Apr 2024 23:15:14 +0200 Subject: [PATCH] Make msvc compile by adding the ifdefs back in gelu_backward, fixes #200 --- train_gpt2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/train_gpt2.c b/train_gpt2.c index 87a44bf3d..34b93154a 100644 --- a/train_gpt2.c +++ b/train_gpt2.c @@ -364,8 +364,10 @@ void gelu_forward(float* out, float* inp, int N) { } // we want to use -Ofast optimization, but sadly GeLU breaks, so disable this flag just for it (#168) -#pragma float_control(precise, on, push) // On msvc /fp:fast is a lot faster, but the expf inside coshf breaks the model +#pragma float_control(precise, on, push) +#if defined(__GNUC__) && !defined(__clang__) __attribute__((optimize("no-finite-math-only"))) // same for gcc -Ofast +#endif void gelu_backward(float* dinp, float* inp, float* dout, int N) { for (int i = 0; i < N; i++) { float x = inp[i];