Download neuro_compiler/cli.py from chrisuser/neuro-compiler: direct link, hf CLI and curl.
- Browser
- Download file 1.19 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.19 kB
| import argparse | |
| from pathlib import Path | |
| from . import NeuralCompiler | |
| def main(): | |
| p=argparse.ArgumentParser(description='Experimental neural compiler; callable x86-64 SysV bytes, no native execution.') | |
| source=p.add_mutually_exclusive_group(required=True); source.add_argument('--source'); source.add_argument('--file',type=Path) | |
| p.add_argument('--model',default='chrisuser/neuro-compiler'); p.add_argument('--revision'); p.add_argument('--device',choices=['auto','cuda','cpu'],default='auto'); p.add_argument('--output',type=Path); p.add_argument('--verify',action='store_true') | |
| a=p.parse_args(); text=a.source if a.source is not None else a.file.read_text(encoding='utf8') | |
| code=NeuralCompiler.from_pretrained(a.model,device=a.device,revision=a.revision).compile(text) | |
| if a.verify: | |
| from .verification import verify | |
| import json | |
| report=verify(text,code); print(json.dumps(report)) | |
| if not report['semantic']: raise SystemExit('Sampled semantics failed; output file not written') | |
| if a.output: | |
| with a.output.open('xb') as f: f.write(code) | |
| else: print(code.hex(' ')) | |
| if __name__=='__main__': main() | |