You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

tobf16.c 1.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <stdio.h>
  2. #include "common.h"
  3. #ifdef FUNCTION_PROFILE
  4. #include "functable.h"
  5. #endif
  6. #if defined(DOUBLE_PREC)
  7. #define FLOAT_TYPE double
  8. #elif defined(SINGLE_PREC)
  9. #define FLOAT_TYPE float
  10. #else
  11. #endif
  12. #ifndef CBLAS
  13. void NAME(blasint *N, FLOAT_TYPE *in, blasint *INC_IN, bfloat16 *out, blasint *INC_OUT){
  14. BLASLONG n = *N;
  15. BLASLONG inc_in = *INC_IN;
  16. BLASLONG inc_out = *INC_OUT;
  17. PRINT_DEBUG_NAME;
  18. if (n <= 0) return;
  19. IDEBUG_START;
  20. FUNCTION_PROFILE_START();
  21. if (inc_in < 0) in -= (n - 1) * inc_in;
  22. if (inc_out < 0) out -= (n - 1) * inc_out;
  23. #if defined(DOUBLE_PREC)
  24. D_TO_BF16_K(n, in, inc_in, out, inc_out);
  25. #elif defined(SINGLE_PREC)
  26. S_TO_BF16_K(n, in, inc_in, out, inc_out);
  27. #else
  28. #endif
  29. FUNCTION_PROFILE_END(1, 2 * n, 2 * n);
  30. IDEBUG_END;
  31. }
  32. #else
  33. void CNAME(blasint n, FLOAT_TYPE *in, blasint inc_in, bfloat16 *out, blasint inc_out){
  34. PRINT_DEBUG_CNAME;
  35. if (n <= 0) return;
  36. IDEBUG_START;
  37. FUNCTION_PROFILE_START();
  38. if (inc_in < 0) in -= (n - 1) * inc_in;
  39. if (inc_out < 0) out -= (n - 1) * inc_out;
  40. #if defined(DOUBLE_PREC)
  41. D_TO_BF16_K(n, in, inc_in, out, inc_out);
  42. #elif defined(SINGLE_PREC)
  43. S_TO_BF16_K(n, in, inc_in, out, inc_out);
  44. #endif
  45. FUNCTION_PROFILE_END(1, 2 * n, 2 * n);
  46. IDEBUG_END;
  47. }
  48. #endif