From dda993f3dd3c753dfd580d485b39c1001830fee4 Mon Sep 17 00:00:00 2001 From: AlexeyAB <alexeyab84@gmail.com> Date: Thu, 22 Feb 2018 19:54:40 +0000 Subject: [PATCH] Use half_float16 instead of float32 if defined both CUDNN and CUDNN_HALF. Use Tensor Cores. --- src/utils.h | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/utils.h b/src/utils.h index 7e49818..9949d6d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -4,8 +4,14 @@ #include <time.h> #include "list.h" -#define SECRET_NUM -1234 +#if defined(_MSC_VER) && _MSC_VER < 1900 + #define snprintf(buf,len, format,...) _snprintf_s(buf, len,len, format, __VA_ARGS__) +#endif +#define SECRET_NUM -1234 +#define TWO_PI 6.2831853071795864769252866 + +int *read_map(char *filename); void shuffle(void *arr, size_t n, size_t size); void sorta_shuffle(void *arr, size_t n, size_t size, size_t sections); void free_ptrs(void **ptrs, int n); @@ -18,7 +24,7 @@ void write_all(int fd, char *buffer, size_t bytes); int read_all_fail(int fd, char *buffer, size_t bytes); int write_all_fail(int fd, char *buffer, size_t bytes); -char *find_replace(char *str, char *orig, char *rep); +void find_replace(char *str, char *orig, char *rep, char *output); void error(const char *s); void malloc_error(); void file_error(char *s); @@ -36,16 +42,19 @@ void translate_array(float *a, int n, float s); int max_index(float *a, int n); float constrain(float min, float max, float a); +int constrain_int(int a, int min, int max); float mse_array(float *a, int n); float rand_normal(); size_t rand_size_t(); float rand_uniform(float min, float max); +float rand_scale(float s); int rand_int(int min, int max); float sum_array(float *a, int n); float mean_array(float *a, int n); void mean_arrays(float **a, int n, int els, float *avg); float variance_array(float *a, int n); float mag_array(float *a, int n); +float dist_array(float *a, float *b, int n, int sub); float **one_hot_encode(float *a, int n, int k); float sec(clock_t clocks); int find_int_arg(int argc, char **argv, char *arg, int def); @@ -53,6 +62,10 @@ int find_arg(int argc, char* argv[], char *arg); char *find_char_arg(int argc, char **argv, char *arg, char *def); int sample_array(float *a, int n); +void print_statistics(float *a, int n); +unsigned int random_gen(); +float random_float(); +float rand_uniform_strong(float min, float max); #endif -- Gitblit v1.10.0