mirror of
https://github.com/stevenrobertson/cuburn.git
synced 2025-02-05 11:40:04 -05:00
Add genome hash
This commit is contained in:
parent
909643c3b4
commit
3666d4bee8
@ -1,5 +1,6 @@
|
|||||||
import base64
|
import base64
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from hashlib import sha1
|
||||||
|
|
||||||
from cuburn.code.util import crep
|
from cuburn.code.util import crep
|
||||||
import spectypes
|
import spectypes
|
||||||
@ -51,6 +52,18 @@ def unflatten(dct):
|
|||||||
go(out, k.split('.'), v)
|
go(out, k.split('.'), v)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
def hash(gnm):
|
||||||
|
"""
|
||||||
|
Produce a genome hash. Genome hashes only consider parameters that affect
|
||||||
|
compilation; if two genomes has equally, their iteration kernels may be
|
||||||
|
shared.
|
||||||
|
"""
|
||||||
|
# For now, this has to be kept in sync with the code manually. This is
|
||||||
|
# easy, since the only thing which we depend on when compiling is the
|
||||||
|
# presence or absence of certain keys, but enumerated parameters may play
|
||||||
|
# into it at some point in the future.
|
||||||
|
return sha1('\n'.join(flatten(gnm).keys())).hexdigest()
|
||||||
|
|
||||||
def resolve_spec(sp, path):
|
def resolve_spec(sp, path):
|
||||||
for name in path:
|
for name in path:
|
||||||
if isinstance(sp, spectypes.Map):
|
if isinstance(sp, spectypes.Map):
|
||||||
|
Loading…
Reference in New Issue
Block a user