| 1813 | } |
| 1814 | |
| 1815 | string AvailableArrayName(const Model& model, const string& name) { |
| 1816 | string sanitized_name = SanitizeNameForTFNode(name); |
| 1817 | if (!model.HasArray(sanitized_name) && |
| 1818 | !model.IsOptionalArray(sanitized_name)) { |
| 1819 | return sanitized_name; |
| 1820 | } |
| 1821 | const int kNumSuffixesToTry = 1000; |
| 1822 | for (int i = 0; i < kNumSuffixesToTry; i++) { |
| 1823 | const string& name_with_suffix = |
| 1824 | toco::port::StringF("%s_%d", sanitized_name, i); |
| 1825 | if (!model.HasArray(name_with_suffix) && |
| 1826 | !model.IsOptionalArray(name_with_suffix)) { |
| 1827 | return name_with_suffix; |
| 1828 | } |
| 1829 | } |
| 1830 | LOG(FATAL) << "Could not find an available array name starting with " |
| 1831 | << sanitized_name << ". Tried " << kNumSuffixesToTry |
| 1832 | << " suffixes, all were taken!"; |
| 1833 | return ""; |
| 1834 | } |
| 1835 | |
| 1836 | string ShapeToString(const Shape& shape) { |
| 1837 | if (shape.dimensions_count() == 0) { |
no test coverage detected