async import(keys, values) {
          this.checkKeyAndValueTensor(keys, values);
          // We only store the primitive values of the keys, this allows lookup
          // to be O(1).
          const $keys = await keys.data();
          // Clear the hashTable before inserting new values.
          this.tensorMap.forEach(value => value.dispose());
          this.tensorMap.clear();
          return tfc.tidy(() => {
              const $values = tfc.unstack(values);
              const keysLength = $keys.length;
              const valuesLength = $values.length;
              tfc.util.assert(keysLength === valuesLength, () => `The number of elements doesn't match, keys has ` +
                  `${keysLength} elements, the values has ${valuesLength} ` +
                  `elements.`);
              for (let i = 0; i < keysLength; i++) {
                  const key = $keys[i];
                  const value = $values[i];
                  tfc.keep(value);
                  this.tensorMap.set(key, value);
              }
              return this.handle;
          });
      }
/**
       * Replaces the contents of the table with the specified keys and values.
       * @param keys Keys to store in the hashtable.
       * @param values Values to store in the hashtable.
       */
Replaces the contents of the table with the specified keys and values.
@param keys Keys to store in the hashtable.
@param values Values to store in the hashtable.
Replaces the contents of the table with the specified keys and values . @param keys Keys to store in the hashtable . @param values Values to store in the hashtable .
async import(keys, values) {
          this.checkKeyAndValueTensor(keys, values);
          const $keys = await keys.data();
          this.tensorMap.forEach(value => value.dispose());
          this.tensorMap.clear();
          return tfc.tidy(() => {
              const $values = tfc.unstack(values);
              const keysLength = $keys.length;
              const valuesLength = $values.length;
              tfc.util.assert(keysLength === valuesLength, () => `The number of elements doesn't match, keys has ` +
                  `${keysLength} elements, the values has ${valuesLength} ` +
                  `elements.`);
              for (let i = 0; i < keysLength; i++) {
                  const key = $keys[i];
                  const value = $values[i];
                  tfc.keep(value);
                  this.tensorMap.set(key, value);
              }
              return this.handle;
          });
      }
async import ( keys , values ) { this . checkKeyAndValueTensor ( keys , values ) ; const $keys = await keys . data ( ) ; this . tensorMap . forEach ( value => value . dispose ( ) ) ; this . tensorMap . clear ( ) ; return tfc . tidy ( ( ) => { const $values = tfc . unstack ( values ) ; const keysLength = $keys . length ; const valuesLength = $values . length ; tfc . util . assert ( keysLength === valuesLength , ( ) => ` ` + ` ${ keysLength } ${ valuesLength } ` + ` ` ) ; for ( let i = 0 ; i < keysLength ; i ++ ) { const key = $keys [ i ] ; const value = $values [ i ] ; tfc . keep ( value ) ; this . tensorMap . set ( key , value ) ; } return this . handle ; } ) ; }
Replaces the contents of the table with the specified keys and values.
Replaces the contents of the table with the specified keys and values .
// We only store the primitive values of the keys, this allows lookup // to be O(1). // Clear the hashTable before inserting new values.