def convert_from_yaml_config(yamlConfig): model = None if 'OnnxModel' in yamlConfig: if __onnx_enabled__: model = onnx_to_hls(yamlConfig) else: raise Exception("ONNX not found. Please install ONNX.") elif 'PytorchModel' in yamlConfig: if __pytorch_enabled__: model = pytorch_to_hls(yamlConfig) else: raise Exception("PyTorch not found. Please install PyTorch.") elif 'TensorFlowModel' in yamlConfig: if __tensorflow_enabled__: model = tf_to_hls(yamlConfig) else: raise Exception("TensorFlow not found. Please install TensorFlow.") else: model = keras_to_hls(yamlConfig) return model
def convert_from_config(config): """Convert to hls4ml model based on the provided configuration. Arguments: config: A string containing the path to the YAML configuration file on the filesystem or a dict containig the parsed configuration. Returns: HLSModel: hls4ml model. """ if isinstance(config, str): yamlConfig = parse_yaml_config(config) else: yamlConfig = config model = None if 'OnnxModel' in yamlConfig: if __onnx_enabled__: model = onnx_to_hls(yamlConfig) else: raise Exception("ONNX not found. Please install ONNX.") elif 'PytorchModel' in yamlConfig: if __pytorch_enabled__: model = pytorch_to_hls(yamlConfig) else: raise Exception("PyTorch not found. Please install PyTorch.") elif 'TensorFlowModel' in yamlConfig: if __tensorflow_enabled__: model = tf_to_hls(yamlConfig) else: raise Exception("TensorFlow not found. Please install TensorFlow.") else: model = keras_to_hls(yamlConfig) return model