blob: 87c5ef16bc532bb5c8e8426f3b607ef470d30242 [file] [log] [blame]
Lei Zhangfe4403e2021-06-01 15:09:43 -04001#!/usr/bin/env python3
2
3# Copyright 2021 The IREE Authors
4#
5# Licensed under the Apache License v2.0 with LLVM Exceptions.
6# See https://llvm.org/LICENSE.txt for license information.
7# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8"""Generates a flagfile for iree-benchmark-module."""
9
10import argparse
11import os
12
13
14def parse_arguments():
15 """Parses command line arguments."""
16 parser = argparse.ArgumentParser()
17 parser.add_argument("--module_file",
18 type=str,
19 required=True,
20 metavar="<module-file>",
21 help="The name of the module file")
22 parser.add_argument("--driver",
23 type=str,
24 required=True,
25 metavar="<driver>",
26 help="The name of the IREE driver")
27 parser.add_argument("--entry_function",
28 type=str,
29 required=True,
30 metavar="<entry-function>",
31 help="The name of the entry function")
32 parser.add_argument("--function_inputs",
33 type=str,
34 required=True,
35 metavar="<function-inputs>",
36 help="A list of comma-separated function inputs")
37 parser.add_argument("--additional_args",
38 type=str,
39 required=True,
40 metavar="<additional-cl-args>",
41 help="Additional command-line arguments")
42 parser.add_argument("-o",
43 "--output",
44 type=str,
45 required=True,
46 metavar="<output-file>",
47 help="Output file to write to")
48 return parser.parse_args()
49
50
51def main(args):
52 lines = [
53 f"--driver={args.driver}", f"--module_file={args.module_file}",
54 f"--entry_function={args.entry_function}"
55 ]
56 lines.extend([
57 ("--function_input=" + e) for e in args.function_inputs.split(",")
58 ])
59 lines.extend(args.additional_args.split(";"))
60 content = "\n".join(lines) + "\n"
61
62 with open(args.output, "w") as f:
63 f.writelines(content)
64
65
66if __name__ == "__main__":
67 main(parse_arguments())