(scopedName: string)
| 88 | * end of the name, so it takes the form 'scope/name_1', 'scope/name_2', etc. |
| 89 | */ |
| 90 | export function getUniqueTensorName(scopedName: string): string { |
| 91 | if (!isValidTensorName(scopedName)) { |
| 92 | throw new Error('Not a valid tensor name: \'' + scopedName + '\''); |
| 93 | } |
| 94 | if (!nameMap.has(scopedName)) { |
| 95 | nameMap.set(scopedName, 0); |
| 96 | } |
| 97 | const index = nameMap.get(scopedName); |
| 98 | nameMap.set(scopedName, nameMap.get(scopedName) + 1); |
| 99 | |
| 100 | if (index > 0) { |
| 101 | const result = `${scopedName}_${index}`; |
| 102 | // Mark the composed name as used in case someone wants |
| 103 | // to call getUniqueTensorName("name_1"). |
| 104 | nameMap.set(result, 1); |
| 105 | return result; |
| 106 | } else { |
| 107 | return scopedName; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | const tensorNameRegex = new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/); |
| 112 |
no test coverage detected
searching dependent graphs…