builtin_fp16.cc 513 Bytes
Newer Older
1 2 3 4 5 6
/*!
 * Copyright (c) 2018 by Contributors
 * \file builtin_fp16.cc
 * \brief Functions for conversion between fp32 and fp16
*/
#include <builtin_fp16.h>
7
#include <tvm/runtime/c_runtime_api.h>
8

9
extern "C" {
10

11 12 13
// disable under msvc
#ifndef _MSC_VER

14
TVM_DLL TVM_WEAK uint16_t __gnu_f2h_ieee(float a) {
15 16 17
  return __truncXfYf2__<float, uint32_t, 23, uint16_t, uint16_t, 10>(a);
}

18
TVM_DLL TVM_WEAK float __gnu_h2f_ieee(uint16_t a) {
19 20 21
  return __extendXfYf2__<uint16_t, uint16_t, 10, float, uint32_t, 23>(a);
}

22
#endif
23
}