"model/git@developer.sourcefind.cn:OpenDAS/ollama.git" did not exist on "33801c1597edca5dd04c5de117db89b5bc27f43a"
Unverified Commit 27f8e6b9 authored by huangtingwei's avatar huangtingwei Committed by GitHub
Browse files

fix multimodal hash feature (#5083)

parent afb752bc
...@@ -198,8 +198,15 @@ class MultimodalDataItem: ...@@ -198,8 +198,15 @@ class MultimodalDataItem:
Set the pad value after first hashign the data Set the pad value after first hashign the data
""" """
def tensor_hash(f):
f_list = flatten_nested_list(f)
f_cat = torch.concat(f_list).contiguous().numpy().tobytes()
return hash(f_cat)
def hash_feature(f): def hash_feature(f):
if isinstance(f, list): if isinstance(f, list):
if isinstance(f[0], torch.Tensor):
return tensor_hash(f)
return hash(tuple(flatten_nested_list(f))) return hash(tuple(flatten_nested_list(f)))
elif isinstance(f, np.ndarray): elif isinstance(f, np.ndarray):
arr = np.ascontiguousarray(f) arr = np.ascontiguousarray(f)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment