junrushao1994 edited a comment on pull request #8862:
URL: https://github.com/apache/tvm/pull/8862#issuecomment-906864735
To do this in a simple and non-intrusive way, we may leverage TVM's global
packed function registry. Example:
```python
def workload_key(self) -> str:
str_dag = _ffi_api.ComputeDAGPrintDAG(self, True)
....
hash_func = get_global_func("auto_scheduler.compute_dag.hash_func",
allow_missing=True)
if hash_func is None:
hash_key = hashlib.md5(str_dag).hexdigest()
else:
hash_key = hash_func(str_dag)
....
```
If a 3rd party repo wants to customize the hash function, it just need to
register the hash function:
```python
@register_func("auto_scheduler.compute_dag.hash_func")
def my_hash_func(str_dag) -> str:
...
```
The key methods are:
- tvm._ffi.get_global_func
- tvm._ffi.register_func
@comaniac @jcf94 @AndrewZhaoLuo let me know what you guys think
--
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]