Download neuro_compiler/cli.py from chrisuser/neuro-compiler: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/chrisuser/neuro-compiler/resolve/main/neuro_compiler/cli.py
- Command line
-
hf download hf://chrisuser/neuro-compiler/neuro_compiler/cli.py
-
curl -L -o cli.py https://huggingface.co/chrisuser/neuro-compiler/resolve/main/neuro_compiler/cli.py
1.16 kB
| import argparse,json | |
| from pathlib import Path | |
| from . import NeuralCompiler | |
| def main(): | |
| p=argparse.ArgumentParser(description='Frozen hybrid compiler; raw x86-64 SysV bytes, never native execution') | |
| group=p.add_mutually_exclusive_group(required=True);group.add_argument('--source');group.add_argument('--file',type=Path) | |
| p.add_argument('--model',default='chrisuser/neuro-compiler');p.add_argument('--revision',default='0.3.0');p.add_argument('--device',choices=('auto','cpu','cuda'),default='auto');p.add_argument('--output',type=Path);p.add_argument('--verify',action='store_true');a=p.parse_args() | |
| source=a.source if a.source is not None else a.file.read_text(encoding='utf-8');code=NeuralCompiler.from_pretrained(a.model,revision=a.revision,device=a.device).compile(source) | |
| if a.verify: | |
| from .verification import verify | |
| report=verify(source,code);print(json.dumps(report)) | |
| if not report['semantic'] or not report['abi']:raise SystemExit('Sampled verification failed; no output written') | |
| if a.output: | |
| with a.output.open('xb') as f:f.write(code) | |
| else:print(code.hex(' ')) | |
| if __name__=='__main__':main() | |