NNFusion relies on implicit conversion to support half arithmetic operation, which may error out in some cases:
more than one implicit conversion
half a;
half b = sqrt(a);
/*
error: more than one instance of overloaded function "sqrt" matches the argument list:
function "std::sqrt(long double)"
function "std::sqrt(float)"
argument types are: (__half)
*/
Implicit conversion changes output data type, then the following operator may get unexpected input type
half a;
half b = a * normcdf(a); // normcdf returns a float, so * is on half and (unexpected) float
/*
error: more than one operator "*" matches these operands:
built-in operator "arithmetic * arithmetic"
function "operator*(const __half &, const __half &)"
operand types are: __half * float
*/
No conversion from/to some type
int64_t a;
half b = (half)a;
/*
error: more than one constructor applies to convert from "int64_t" to "__half":
function "__half::__half(float)"
function "__half::__half(double)"
function "__half::__half(short)"
function "__half::__half(unsigned short)"
function "__half::__half(int)"
function "__half::__half(unsigned int)"
function "__half::__half(long long)"
function "__half::__half(unsigned long long)"
*/
Expected behavior
Use half operator, e.g. sqrt->hsqrt
🐛 Bug
NNFusion relies on implicit conversion to support half arithmetic operation, which may error out in some cases:
Expected behavior Use half operator, e.g.
sqrt
->hsqrt