Aharrypotter commented on code in PR #19879:
URL: https://github.com/apache/tvm/pull/19879#discussion_r3464707965


##########
python/tvm/relax/frontend/tflite/tflite_frontend.py:
##########
@@ -759,21 +798,102 @@ def convert_hashtable_import(self, op):
         ):
             raise tvm.error.OpNotImplemented("HASHTABLE_IMPORT requires 
constant keys and values")
 
+        if self._is_tflite_string_type(table_info["key_dtype"]):
+            keys = self._get_string_tensor_value(key_tensor, 
"HASHTABLE_IMPORT")
+        else:
+            keys = self.get_tensor_value(key_tensor)
+        if self._is_tflite_string_type(table_info["value_dtype"]):
+            values = self._get_string_tensor_value(value_tensor, 
"HASHTABLE_IMPORT")
+        else:
+            values = self.get_tensor_value(value_tensor)
+
+        if np.unique(keys).size != keys.size:
+            raise tvm.error.OpNotImplemented(
+                "HASHTABLE_IMPORT with duplicate keys is not supported"
+            )

Review Comment:
   This case already be covered by the existing import-time guard just above
   this block:
   
   ```python
   key_shape = self._get_tensor_shape_tuple(key_tensor)
   value_shape = self._get_tensor_shape_tuple(value_tensor)
   if key_shape != value_shape:
       raise tvm.error.OpNotImplemented("HASHTABLE_IMPORT requires keys and 
values same shape")
   ```
   
   This runs before the keys and values are stored for `HASHTABLE_FIND`, so a
   mismatched import should be rejected before the later `zip` path can silently
   truncate anything. I do not think an extra `keys.shape != values.shape` check
   changes the frontend behavior here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to