MCPcopy Index your code
hub / github.com/tensorflow/tfjs / getUniqueTensorName

Function getUniqueTensorName

tfjs-layers/src/common.ts:90–109  ·  view source on GitHub ↗
(scopedName: string)

Source from the content-addressed store, hash-verified

88 * end of the name, so it takes the form 'scope/name_1', 'scope/name_2', etc.
89 */
90export 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
111const tensorNameRegex = new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);
112

Callers 3

constructorMethod · 0.90
common_test.tsFile · 0.90
constructorMethod · 0.90

Calls 4

isValidTensorNameFunction · 0.85
hasMethod · 0.80
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…