Returns 1 if 'obj' is an instance of 'type_name' Returns 0 otherwise. Returns -1 if an error occurred (e.g., if 'type_name' is not registered.)
| 196 | // Returns 0 otherwise. |
| 197 | // Returns -1 if an error occurred (e.g., if 'type_name' is not registered.) |
| 198 | int IsInstanceOfRegisteredType(PyObject* obj, const char* type_name) { |
| 199 | PyObject* type_obj = GetRegisteredType(type_name); |
| 200 | if (TF_PREDICT_FALSE(type_obj == nullptr)) { |
| 201 | PyErr_SetString(PyExc_RuntimeError, |
| 202 | tensorflow::strings::StrCat( |
| 203 | type_name, |
| 204 | " type has not been set. " |
| 205 | "Please register the type with the identifier \"", |
| 206 | type_name, "\" using RegisterType.") |
| 207 | .c_str()); |
| 208 | return -1; |
| 209 | } |
| 210 | return PyObject_IsInstance(obj, type_obj); |
| 211 | } |
| 212 | |
| 213 | // Returns 1 if `o` is considered a mapping for the purposes of Flatten(). |
| 214 | // Returns 0 otherwise. |
no test coverage detected