def generate_code_step(model: Model, config: Config) -> None: """Generate code for the model. Parameters ---------- model : Model Model the code generation is based on config : Config Collection of configurations """ graph: Graph = model.graph params = Params(graph, config) builder = CodeGenerater(graph, params, config) builder.reuse_output_buffers() builder.generate_files_from_template() builder.generate_inputs() if config.activate_hard_quantization: builder.generate_scaling_factors() if config.threshold_skipping: builder.generate_thresholds()
if __name__ == "__main__": if sys.version_info[0] < 3: message = ("This program requires version 3 of Python." + "\nVisit: https://www.python.org/downloads/") OnFail(message) thisDir = os.path.dirname(os.path.abspath(__file__)) paramDir = os.path.join(thisDir, "params.txt") if not os.path.isfile(paramDir): OnFail("Cannot locate params.txt in " + paramDir) uID = uuid.uuid4().int paramsFile = DataFile(paramDir) params = Params(thisDir, uID, paramsFile.root) random.seed(params.uID) if not params.gamePath.endswith("data"): params.gamePath = os.path.join(params.gamePath, "data") if not os.path.isdir(params.gamePath): OnFail("Cannot locate game data files in " + params.gamePath) if params.usePlugins: if not params.pluginPath.endswith("plugins"): params.pluginPath = os.path.join(params.pluginPath, "plugins") if not os.path.isdir(params.pluginPath): print("Cannot find plugin directory in " + params.pluginPath) userIn = input("Continue with only vanilla ships? y/n: ") no = ("n", "no", "No", "NO") if userIn in no: