| 1325 | } |
| 1326 | |
| 1327 | void TF_OperationGetAttrString(TF_Operation* oper, const char* attr_name, |
| 1328 | void* value, size_t max_length, |
| 1329 | TF_Status* status) { |
| 1330 | const auto* attr = GetAttrValue(oper, attr_name, status); |
| 1331 | if (TF_GetCode(status) != TF_OK) return; |
| 1332 | if (attr->value_case() != tensorflow::AttrValue::kS) { |
| 1333 | status->status = |
| 1334 | InvalidArgument("Attribute '", attr_name, "' is not a string"); |
| 1335 | return; |
| 1336 | } |
| 1337 | if (max_length <= 0) { |
| 1338 | return; |
| 1339 | } |
| 1340 | const auto& s = attr->s(); |
| 1341 | std::memcpy(value, s.data(), std::min<size_t>(s.length(), max_length)); |
| 1342 | } |
| 1343 | |
| 1344 | void TF_OperationGetAttrStringList(TF_Operation* oper, const char* attr_name, |
| 1345 | void** values, size_t* lengths, |