Check whether opname with type T is registered as an OneDNN operator that will go through name change. @input: name of the op @input: T datatype to be used for checking op @return: true if opname is registered as OneDNN op that will go through name change; false otherwise
| 201 | // @return: true if opname is registered as OneDNN op that will go through name |
| 202 | // change; false otherwise |
| 203 | static inline bool IsMklNameChangeOp(const string& op_name, DataType T) { |
| 204 | string kernel = KernelsRegisteredForOp(op_name); |
| 205 | // String returned by KernelsRegisteredForOp looks like below: |
| 206 | // |
| 207 | // Op = _MklMatMul, kernels = |
| 208 | // device='CPU'; label='MklNameChangeOp'; T in [DT_COMPLEX128] |
| 209 | // device='CPU'; label='MklNameChangeOp'; T in [DT_COMPLEX64] |
| 210 | // device='CPU'; label='MklNameChangeOp'; T in [DT_DOUBLE] |
| 211 | // device='CPU'; label='MklNameChangeOp'; T in [DT_FLOAT] |
| 212 | |
| 213 | // Now we just construct a search string to match what we are looking for. |
| 214 | string search_string = kMklNameChangeOpLabelPattern; |
| 215 | search_string += string(";") + string(" T in ["); |
| 216 | search_string += DataType_Name(T) + string("]"); |
| 217 | |
| 218 | // Temporarily replacing earlier check by adding a type-specific check so |
| 219 | // that we can selectively decide which type is supported by OneDNN operators. |
| 220 | // That way kernel registration does not decide which operators we support. |
| 221 | // We are using this change to temporarily disable BFLOAT16 support. Once |
| 222 | // we want to enable it, we will go back to earlier check. |
| 223 | bool isTypeAllowed = false; |
| 224 | if (kernel.find(search_string) != string::npos) { |
| 225 | isTypeAllowed = (T == DT_COMPLEX128 || T == DT_COMPLEX64 || |
| 226 | T == DT_DOUBLE || T == DT_FLOAT); |
| 227 | if (!isTypeAllowed) { |
| 228 | if (T == DT_BFLOAT16) { |
| 229 | if (IsBF16SupportedByOneDNNOnThisCPU()) { |
| 230 | isTypeAllowed = true; |
| 231 | } else { |
| 232 | // Restrict bfloat16 ops to platforms with at least AVX512 support, |
| 233 | // fall back to Eigen implementation otherwise. |
| 234 | BF16UnsupportedWarning(); |
| 235 | isTypeAllowed = false; |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | return isTypeAllowed; |
| 240 | } |
| 241 | |
| 242 | return false; |
| 243 | } |
| 244 | |
| 245 | // Check if the operator with 'op_name' and type 'T' is an OneDNN operator that |
| 246 | // will either understand input tensors in OneDNN layout or will go through name |
no test coverage detected