MCPcopy Index your code
hub / github.com/PaddlePaddle/PaddleRec / Config

Class Config

tools/inference/java/src/main/java/Config.java:52–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50import org.apache.commons.cli.*;
51
52public class Config {
53 public static int threadNum;
54 public static int batchSize;
55 public static float cpuUsageRatio;
56 public static int iteration;
57 public static String outPerformanceFile;
58 public static String inputdata;
59 public static String modelFile;
60
61 public Config() {};
62
63 public static void ReadConfig(String[] args) {
64 System.out.println(Arrays.asList(args));
65 Option opt1 = new Option("t", "threadNum", true, "threrad num");
66 opt1.setRequired(true);
67 Option opt2 = new Option("bsz", "batchSize", true, "batch size");
68 opt2.setRequired(true);
69 Option opt3 = new Option("cr", "cpuRatio", true, "cpu usage ratio");
70 opt3.setRequired(true);
71 Option opt4 = new Option("it", "iteration", true, "iteration num");
72 opt4.setRequired(true);
73 Option opt5 = new Option("op", "outPerformanceFile", true, "perfomance file");
74 opt5.setRequired(true);
75 Option opt6 = new Option("inputdata", "inputdata", true, "training file");
76 opt6.setRequired(true);
77 Option opt7 = new Option("modelFile", "modelFile", true, "model file");
78 opt7.setRequired(true);
79
80 Options options = new Options();
81 options.addOption(opt1);
82 options.addOption(opt2);
83 options.addOption(opt3);
84 options.addOption(opt4);
85 options.addOption(opt5);
86 options.addOption(opt6);
87 options.addOption(opt7);
88
89 CommandLine cli = null;
90 CommandLineParser cliParser = new DefaultParser();
91 HelpFormatter helpFormatter = new HelpFormatter();
92 try {
93 cli = cliParser.parse(options, args);
94 } catch (ParseException e) {
95 helpFormatter.printHelp(">>>>>> test cli options", options);
96 e.printStackTrace();
97 }
98
99 if (cli.hasOption("t")) {
100 threadNum = Integer.parseInt(cli.getOptionValue("t", "1"));
101 System.out.println(String.format(">>>>>> thread num: %s", threadNum));
102 }
103 if (cli.hasOption("bsz")) {
104 batchSize = Integer.parseInt(cli.getOptionValue("bsz", "1"));
105 System.out.println(String.format(">>>>>> batch size: %s", batchSize));
106 }
107 if (cli.hasOption("cr")) {
108 cpuUsageRatio = Float.parseFloat(cli.getOptionValue("cr", "1.0"));
109 System.out.println(String.format(">>>>>> cpu usage ratio: %s", cpuUsageRatio));

Callers 9

init_predictorFunction · 0.90
init_predictorFunction · 0.90
init_predictorFunction · 0.90
init_predictorFunction · 0.90
init_predictorFunction · 0.90
init_predictorFunction · 0.90
init_predictorFunction · 0.90
init_predictorFunction · 0.90
init_predictorFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected