Download neuro_compiler/cli.py from chrisuser/NeuroCC_0.4.0: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/chrisuser/NeuroCC_0.4.0/resolve/main/neuro_compiler/cli.py
- Command line
-
hf download hf://chrisuser/NeuroCC_0.4.0/neuro_compiler/cli.py
-
curl -L -o cli.py https://huggingface.co/chrisuser/NeuroCC_0.4.0/resolve/main/neuro_compiler/cli.py
1.56 kB
| """Command-line interface for isolated NeuroCC source compilation.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import sys | |
| from .api import NeuroCompiler | |
| def main(argv=None): | |
| p = argparse.ArgumentParser(description=__doc__) | |
| p.add_argument('--input', type=Path, nargs='+', help='UTF-8 source files') | |
| p.add_argument('--stdin', action='store_true', help='read one source from stdin') | |
| p.add_argument('--output', type=Path, help='JSON output path; stdout by default') | |
| p.add_argument('--device', default='auto') | |
| p.add_argument('--implementation', choices=('d5a', 'd5-final'), default='d5a') | |
| p.add_argument('--hyperopt', action='store_true', | |
| help='enable the optional frozen H7 hyperoptimizer') | |
| a = p.parse_args(argv) | |
| if not a.input and not a.stdin: | |
| p.error('provide --input or --stdin') | |
| sources = [x.read_text(encoding='utf-8') for x in (a.input or [])] | |
| if a.stdin: | |
| sources.append(sys.stdin.read()) | |
| compiler = NeuroCompiler(device=a.device, implementation=a.implementation, | |
| hyperopt=a.hyperopt) | |
| results = compiler.compile_batch(sources) | |
| payload = [dict(valid=r.valid, size=r.size, code_hex=r.code.hex(), | |
| diagnostics=r.record) for r in results] | |
| text = json.dumps(payload, indent=2) + '\n' | |
| if a.output: | |
| a.output.write_text(text, encoding='utf-8') | |
| else: | |
| print(text, end='') | |
| return 0 if all(x['valid'] for x in payload) else 2 | |
| if __name__ == '__main__': | |
| raise SystemExit(main()) | |