Skip to content

Commit

Permalink
Fix table recreation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedsabie committed Oct 5, 2022
1 parent e33267c commit da7ed9c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion e2e/integration_tests/convert_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def lookup(input):
return {
"async": False,
"inputs": {
"Placeholder:0": {
"input:0": {
"value": ["a", "b", "c"], "shape": [3], "dtype": "string"
}
},
Expand Down
21 changes: 14 additions & 7 deletions tfjs-converter/src/operations/executors/hash_table_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@ export const executeOp: InternalOpAsyncExecutor = async(
switch (node.op) {
case 'HashTable':
case 'HashTableV2': {
const keyDType =
getParamValue('keyDType', node, tensorMap, context) as DataType;
const valueDType =
getParamValue('valueDType', node, tensorMap, context) as DataType;
const existingTableHandle =
resourceManager.getHashTableHandleByName(node.name);
// Table is shared with initializer.
if (existingTableHandle != null) {
return [existingTableHandle];
} else {
const keyDType =
getParamValue('keyDType', node, tensorMap, context) as DataType;
const valueDType =
getParamValue('valueDType', node, tensorMap, context) as DataType;

const hashTable = new HashTable(keyDType, valueDType);
resourceManager.addHashTable(node.name, hashTable);
return [hashTable.handle];
const hashTable = new HashTable(keyDType, valueDType);
resourceManager.addHashTable(node.name, hashTable);
return [hashTable.handle];
}
}
case 'LookupTableImport':
case 'LookupTableImportV2': {
Expand Down

0 comments on commit da7ed9c

Please sign in to comment.