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.

bf16to.c 1.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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, bfloat16 *in, blasint *INC_IN, FLOAT_TYPE *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_BF16_TO_K(n, in, inc_in, out, inc_out);
  25. #elif defined(SINGLE_PREC)
  26. S_BF16_TO_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, bfloat16 * in, blasint inc_in, FLOAT_TYPE * 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_BF16_TO_K(n, in, inc_in, out, inc_out);
  42. #elif defined(SINGLE_PREC)
  43. S_BF16_TO_K(n, in, inc_in, out, inc_out);
  44. #else
  45. #endif
  46. FUNCTION_PROFILE_END(1, 2 * n, 2 * n);
  47. IDEBUG_END;
  48. }
  49. #endif