microsoft/nnfusion

[BUG] "More than one instance of overloaded function" for half type

mzmssg opened this issue ยท 1 comments

๐Ÿ› Bug

NNFusion relies on implicit conversion to support half arithmetic operation, which may error out in some cases:

  1. 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)
*/
  1. 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
*/
  1. 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

the second bug is fixed by pr #473 . the first and third ones are fixed by the latest antares.