Description
🐛 Describe the bug
Per https://en.cppreference.com/w/cpp/language/extending_std:
It is undefined behavior to add declarations or definitions to namespace std or to any namespace nested within std, with a few exceptions noted below.
The "exceptions noted below" do not seem to include what we're doing in BFloat16-math.h, and specifically don't include adding overloads of functions that take program-defined types.
This problem is currently "theoretical" in that I am not aware of practical issues resulting from this header at this time.
To fix this, we would need to at least put the functions in BFloat16-math.h into a namespace other than std
(either c10
or a new one, like say c10_math
). Then, we could either:
- have callers do
using std::pow
and all the other cmath functions, and rely on ADL to select the c10/c10_math version for half/BFloat16 using
all the std:: functions into our namespace (which IMO argues toward that namespace being a new one likec10_math
).
Versions
N/A
cc @malfet @seemethere @manuelcandales @SherlockNoMad @angelayi