da4ml.codegen package
Subpackages
- da4ml.codegen.cpp package
- da4ml.codegen.verilog package
Module contents
- class da4ml.codegen.HLSModel(solution: Solution, prj_name: str, path: str | Path, flavor: str = 'vitis', print_latency: bool = True, part_name: str = 'xcvu13p-flga2577-2-e', pragma: Sequence[str] | None = None, clock_period: int = 5, clock_uncertainty: float = 0.1, io_delay_minmax: tuple[float, float] = (0.2, 0.4))
Bases:
object
- compile(verbose=False, openmp=True, o3: bool = False, clean=True)
Compile the model to a shared object file
- Parameters:
verbose (bool, optional) – Verbose output, by default False
openmp (bool, optional) – Enable openmp, by default True
o3 (bool | None, optional) – Turn on -O3 flag, by default False
clean (bool, optional) – Remove obsolete shared object files, by default True
- Raises:
RuntimeError – If compilation fails
- predict(data: ndarray[tuple[int, ...], dtype[T]]) ndarray[tuple[int, ...], dtype[T]]
Run the model on the input data.
- Parameters:
data (NDArray[np.floating]) – Input data to the model. The shape is ignored, and the number of samples is determined by the size of the data.
- Returns:
Output of the model in shape (n_samples, output_size).
- Return type:
NDArray[np.floating]
- write()
- class da4ml.codegen.VerilogModel(solution: Solution | CascadedSolution, prj_name: str, path: str | Path, latency_cutoff: float = -1, print_latency: bool = True, part_name: str = 'xcvu13p-flga2577-2-e', clock_period: float = 5, clock_uncertainty: float = 0.1, io_delay_minmax: tuple[float, float] = (0.2, 0.4), register_layers: int = 1)
Bases:
object
- compile(verbose=False, openmp=True, nproc: int | None = None, o3: bool = False, clean=True)
Compile the generated code to a emulator for logic simulation.
- Parameters:
verbose (bool, optional) – Verbose output, by default False
openmp (bool, optional) – Enable openmp, by default True
nproc (int | None, optional) – Number of processes to use for compilation, by default None If None, will use the number of CPU cores, but not more than 32.
o3 (bool | None, optional) – Turn on -O3 flag, by default False
clean (bool, optional) – Remove obsolete shared object files, by default True
- Raises:
RuntimeError – If compilation fails
- predict(data: ndarray[tuple[int, ...], dtype[floating]])
Run the model on the input data.
- Parameters:
data (NDArray[np.floating]) – Input data to the model. The shape is ignored, and the number of samples is determined by the size of the data.
- Returns:
Output of the model in shape (n_samples, output_size).
- Return type:
NDArray[np.float64]
- write()
- da4ml.codegen.binder_gen(csol: CascadedSolution | Solution, module_name: str, II: int = 1, latency_multiplier: int = 1)
- da4ml.codegen.comb_logic_gen(sol: Solution, fn_name: str, print_latency: bool = False, timescale: str | None = None)
- da4ml.codegen.cpp_logic_and_bridge_gen(sol: Solution, fn_name: str, flavor: str, pragmas: list[str] | None = None, n_indent: int = 4, n_base_indent: int = 0, print_latency: bool = False)
- da4ml.codegen.generate_io_wrapper(sol: Solution | CascadedSolution, module_name: str, pipelined: bool = False)
- da4ml.codegen.pipeline_logic_gen(csol: CascadedSolution, name: str, print_latency=False, timescale: str | None = '`timescale 1 ns / 1 ps', register_layers: int = 1)