node = Node(graph, node)
if node.kind == 'data' and node.value is not None and any('bin' in d for u, v, d in graph.out_edges(node.node, data=True)):
- blob = node.value
- blob_hash = hashlib.sha512(blob.tobytes()).hexdigest()
+ # avoid array copying while taking hash
+ blob = node.value if node.value.ndim > 0 else node.value.reshape((1))
+ blob_hash = hashlib.sha512(np.ascontiguousarray(blob).view(np.uint8)).hexdigest()
if blob_hash in bin_hashes and np.array_equal(blob, bin_hashes[blob_hash]['blob']):
graph.node[node.node]['offset'] = bin_hashes[blob_hash]['offset']
if any(v is None for v in values):
return
- node.out_node(0).value = np.array(np.concatenate(values, axis=node.axis), dtype=values[0].dtype)
+ node.out_node(0).value = np.concatenate(values, axis=node.axis).astype(values[0].dtype, copy=False)
node.out_node(0).shape = np.array(node.out_node(0).value.shape, dtype=np.int64)