@@ -194,7 +194,7 @@ def convert_from_keras_model(
194
194
hls_config = None ,
195
195
** kwargs ,
196
196
):
197
- """Convert to hls4ml model based on the provided configuration.
197
+ """Convert Keras model to hls4ml model based on the provided configuration.
198
198
199
199
Args:
200
200
model: Keras model to convert
@@ -221,7 +221,7 @@ def convert_from_keras_model(
221
221
kwargs** (dict, optional): Additional parameters that will be used to create the config of the specified backend
222
222
223
223
Raises:
224
- Exception: If precision and reuse factor are not present in 'hls_config'
224
+ Exception: If precision and reuse factor are not present in 'hls_config'.
225
225
226
226
Returns:
227
227
ModelGraph: hls4ml model.
@@ -256,54 +256,35 @@ def convert_from_pytorch_model(
256
256
hls_config = None ,
257
257
** kwargs ,
258
258
):
259
- """
259
+ """Convert PyTorch model to hls4ml model based on the provided configuration.
260
+
261
+ Args:
262
+ model: PyTorch model to conert.
263
+ input_shape (list): The shape of the input tensor.
264
+ output_dir (str, optional): Output directory of the generated HLS project. Defaults to 'my-hls-test'.
265
+ project_name (str, optional): Name of the HLS project. Defaults to 'myproject'.
266
+ input_data_tb (str, optional): String representing the path of input data in .npy or .dat format that will be
267
+ used during csim and cosim. Defaults to None.
268
+ output_data_tb (str, optional): String representing the path of output data in .npy or .dat format that will be
269
+ used during csim and cosim. Defaults to None.
270
+ backend (str, optional): Name of the backend to use, e.g., 'Vivado' or 'Quartus'. Defaults to 'Vivado'.
271
+ board (str, optional): One of target boards specified in `supported_board.json` file. If set to `None` a default
272
+ device of a backend will be used. See documentation of the backend used.
273
+ part (str, optional): The FPGA part. If set to `None` a default part of a backend will be used.
274
+ See documentation of the backend used. Note that if `board` is specified, the part associated to that board
275
+ will overwrite any part passed as a parameter.
276
+ clock_period (int, optional): Clock period of the design.
277
+ Defaults to 5.
278
+ io_type (str, optional): Type of implementation used. One of
279
+ 'io_parallel' or 'io_stream'. Defaults to 'io_parallel'.
280
+ hls_config (dict, optional): The HLS config.
281
+ kwargs** (dict, optional): Additional parameters that will be used to create the config of the specified backend.
282
+
283
+ Raises:
284
+ Exception: If precision and reuse factor are not present in 'hls_config'.
260
285
261
- Convert a Pytorch model to a hls model.
262
-
263
- Parameters
264
- ----------
265
- model : Pytorch model object.
266
- Model to be converted to hls model object.
267
- input_shape : @todo: to be filled
268
- output_dir (str, optional): Output directory of the generated HLS
269
- project. Defaults to 'my-hls-test'.
270
- project_name (str, optional): Name of the HLS project.
271
- Defaults to 'myproject'.
272
- input_data_tb (str, optional): String representing the path of input data in .npy or .dat format that will be
273
- used during csim and cosim.
274
- output_data_tb (str, optional): String representing the path of output data in .npy or .dat format that will be
275
- used during csim and cosim.
276
- backend (str, optional): Name of the backend to use, e.g., 'Vivado'
277
- or 'Quartus'.
278
- board (str, optional): One of target boards specified in `supported_board.json` file. If set to `None` a default
279
- device of a backend will be used. See documentation of the backend used.
280
- part (str, optional): The FPGA part. If set to `None` a default part of a backend will be used.
281
- See documentation of the backend used. Note that if `board` is specified, the part associated to that board
282
- will overwrite any part passed as a parameter.
283
- clock_period (int, optional): Clock period of the design.
284
- Defaults to 5.
285
- io_type (str, optional): Type of implementation used. One of
286
- 'io_parallel' or 'io_stream'. Defaults to 'io_parallel'.
287
- hls_config (dict, optional): The HLS config.
288
- kwargs** (dict, optional): Additional parameters that will be used to create the config of the specified backend
289
-
290
- Returns
291
- -------
292
- ModelGraph : hls4ml model object.
293
-
294
- See Also
295
- --------
296
- hls4ml.convert_from_keras_model, hls4ml.convert_from_onnx_model
297
-
298
- Examples
299
- --------
300
- >>> import hls4ml
301
- >>> config = hls4ml.utils.config_from_pytorch_model(model, granularity='model')
302
- >>> hls_model = hls4ml.converters.convert_from_pytorch_model(model, hls_config=config)
303
-
304
- Notes
305
- -----
306
- Only sequential Pytorch models are supported for now.
286
+ Returns:
287
+ ModelGraph: hls4ml model.
307
288
"""
308
289
309
290
config = create_config (output_dir = output_dir , project_name = project_name , backend = backend , ** kwargs )
@@ -335,49 +316,37 @@ def convert_from_onnx_model(
335
316
hls_config = None ,
336
317
** kwargs ,
337
318
):
338
- """
319
+ """Convert Keras model to hls4ml model based on the provided configuration.
320
+
321
+ Args:
322
+ model: ONNX model to convert.
323
+ output_dir (str, optional): Output directory of the generated HLS
324
+ project. Defaults to 'my-hls-test'.
325
+ project_name (str, optional): Name of the HLS project.
326
+ Defaults to 'myproject'.
327
+ input_data_tb (str, optional): String representing the path of input data in .npy or .dat format that will be
328
+ used during csim and cosim.
329
+ output_data_tb (str, optional): String representing the path of output data in .npy or .dat format that will be
330
+ used during csim and cosim.
331
+ backend (str, optional): Name of the backend to use, e.g., 'Vivado'
332
+ or 'Quartus'.
333
+ board (str, optional): One of target boards specified in `supported_board.json` file. If set to `None` a default
334
+ device of a backend will be used. See documentation of the backend used.
335
+ part (str, optional): The FPGA part. If set to `None` a default part of a backend will be used.
336
+ See documentation of the backend used. Note that if `board` is specified, the part associated to that board
337
+ will overwrite any part passed as a parameter.
338
+ clock_period (int, optional): Clock period of the design.
339
+ Defaults to 5.
340
+ io_type (str, optional): Type of implementation used. One of
341
+ 'io_parallel' or 'io_stream'. Defaults to 'io_parallel'.
342
+ hls_config (dict, optional): The HLS config.
343
+ kwargs** (dict, optional): Additional parameters that will be used to create the config of the specified backend
344
+
345
+ Raises:
346
+ Exception: If precision and reuse factor are not present in 'hls_config'.
339
347
340
- Convert an ONNX model to a hls model.
341
-
342
- Parameters
343
- ----------
344
- model : ONNX model object.
345
- Model to be converted to hls model object.
346
- output_dir (str, optional): Output directory of the generated HLS
347
- project. Defaults to 'my-hls-test'.
348
- project_name (str, optional): Name of the HLS project.
349
- Defaults to 'myproject'.
350
- input_data_tb (str, optional): String representing the path of input data in .npy or .dat format that will be
351
- used during csim and cosim.
352
- output_data_tb (str, optional): String representing the path of output data in .npy or .dat format that will be
353
- used during csim and cosim.
354
- backend (str, optional): Name of the backend to use, e.g., 'Vivado'
355
- or 'Quartus'.
356
- board (str, optional): One of target boards specified in `supported_board.json` file. If set to `None` a default
357
- device of a backend will be used. See documentation of the backend used.
358
- part (str, optional): The FPGA part. If set to `None` a default part of a backend will be used.
359
- See documentation of the backend used. Note that if `board` is specified, the part associated to that board
360
- will overwrite any part passed as a parameter.
361
- clock_period (int, optional): Clock period of the design.
362
- Defaults to 5.
363
- io_type (str, optional): Type of implementation used. One of
364
- 'io_parallel' or 'io_stream'. Defaults to 'io_parallel'.
365
- hls_config (dict, optional): The HLS config.
366
- kwargs** (dict, optional): Additional parameters that will be used to create the config of the specified backend
367
-
368
- Returns
369
- -------
370
- ModelGraph : hls4ml model object.
371
-
372
- See Also
373
- --------
374
- hls4ml.convert_from_keras_model, hls4ml.convert_from_pytorch_model
375
-
376
- Examples
377
- --------
378
- >>> import hls4ml
379
- >>> config = hls4ml.utils.config_from_onnx_model(model, granularity='model')
380
- >>> hls_model = hls4ml.converters.convert_from_onnx_model(model, hls_config=config)
348
+ Returns:
349
+ ModelGraph: hls4ml model.
381
350
"""
382
351
383
352
config = create_config (output_dir = output_dir , project_name = project_name , backend = backend , ** kwargs )
0 commit comments