zefancainlp's picture
download
raw
1.56 kB
"""Public task-independent source-component fusion interface.
Only `evaluate(source_text)` and the native entry belong to the task adapter.
No solver, region names, desired edits, answer arrays or stage metrics are
arguments to this method. Python and C++ use the same search implementation.
"""
from source_graph import sha
from graph_search import GraphSearch
def fuse_programs(sources,*,entry,language,evaluate,budget,width=4,base=None,
known_originals=None,evaluation_signature=None,journal=None):
if language=='python':
from region_family import RegionFamily
family=RegionFamily(sources,entry,base or next(iter(sources)))
elif language=='cpp':
from cpp_family import CppRegionFamily
family=CppRegionFamily(sources,entry,base)
else:raise ValueError('a language frontend is required')
reusable={}
for key,record in (known_originals or{}).items():
if key not in sources or record.get('source_sha256')!=sha(sources[key]):raise ValueError('known rollout source differs')
if evaluation_signature is None or record.get('evaluation_signature')!=evaluation_signature:raise ValueError('known rollout evaluation protocol differs')
reusable[key]=record
def oracle(config,key):return evaluate(family.emit(config))
result=GraphSearch(family,oracle,budget=budget,width=width,journal=journal,known_originals=reusable).run()
result['source_graph']=family.manifest();result['program']=family.emit(result['best']['config'])if result['best']else None
return result

Xet Storage Details

Size:
1.56 kB
·
Xet hash:
91b17939046da94e4bc69b720f5d270f3fa9f9693208a2c013d89da27103aafd

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.