This function considers a Dimension._value of None to be valid, and sets the value to be -1 in that case.
| 187 | // This function considers a Dimension._value of None to be valid, and sets the |
| 188 | // value to be -1 in that case. |
| 189 | bool ParseDimensionValue(const string& key, PyObject* py_value, |
| 190 | TF_Status* status, int64_t* value) { |
| 191 | if (IsInteger(py_value)) { |
| 192 | return ParseInt64Value(key, py_value, status, value); |
| 193 | } |
| 194 | |
| 195 | tensorflow::Safe_PyObjectPtr dimension_value( |
| 196 | PyObject_GetAttrString(py_value, "_value")); |
| 197 | if (dimension_value == nullptr) { |
| 198 | TF_SetStatus( |
| 199 | status, TF_INVALID_ARGUMENT, |
| 200 | tensorflow::strings::StrCat("Expecting a Dimension for attr ", key, |
| 201 | ", got ", py_value->ob_type->tp_name) |
| 202 | .c_str()); |
| 203 | return false; |
| 204 | } |
| 205 | |
| 206 | if (dimension_value.get() == Py_None) { |
| 207 | *value = -1; |
| 208 | return true; |
| 209 | } |
| 210 | |
| 211 | return ParseInt64Value(key, dimension_value.get(), status, value); |
| 212 | } |
| 213 | |
| 214 | bool ParseStringValue(const string& key, PyObject* py_value, TF_Status* status, |
| 215 | tensorflow::StringPiece* value) { |
no test coverage detected