| 1453 | } |
| 1454 | |
| 1455 | void TF_OperationGetAttrTensorShapeProtoList(TF_Operation* oper, |
| 1456 | const char* attr_name, |
| 1457 | TF_Buffer** values, int max_values, |
| 1458 | TF_Status* status) { |
| 1459 | const auto* attr = GetAttrValue(oper, attr_name, status); |
| 1460 | if (TF_GetCode(status) != TF_OK) return; |
| 1461 | if (attr->value_case() != tensorflow::AttrValue::kList) { |
| 1462 | status->status = |
| 1463 | InvalidArgument("Value for '", attr_name, "' is not a list"); |
| 1464 | return; |
| 1465 | } |
| 1466 | const auto len = std::min(max_values, attr->list().shape_size()); |
| 1467 | for (int i = 0; i < len; ++i) { |
| 1468 | values[i] = TF_NewBuffer(); |
| 1469 | status->status = MessageToBuffer(attr->list().shape(i), values[i]); |
| 1470 | if (TF_GetCode(status) != TF_OK) { |
| 1471 | // Delete everything allocated to far, the operation has failed. |
| 1472 | for (int j = 0; j <= i; ++j) { |
| 1473 | TF_DeleteBuffer(values[j]); |
| 1474 | } |
| 1475 | return; |
| 1476 | } |
| 1477 | } |
| 1478 | } |
| 1479 | |
| 1480 | void TF_OperationGetAttrTensor(TF_Operation* oper, const char* attr_name, |
| 1481 | TF_Tensor** value, TF_Status* status) { |