da4ml.trace package

Subpackages

Submodules

da4ml.trace.fixed_variable module

class da4ml.trace.fixed_variable.FixedVariable(low: float | Decimal, high: float | Decimal, step: float | Decimal, latency: float | None = None, hwconf=(-1, -1, -1), opr: str = 'new', cost: float | None = None, _from: tuple[FixedVariable, ...] = (), _factor: float | Decimal = 1.0, _data: Decimal | None = None, _id: UUID | None = None)

Bases: object

classmethod from_const(const: float | Decimal, hwconf: HWConfig, latency: float, _factor: float | Decimal)
classmethod from_kif(k: int | bool, i: int, f: int, **kwargs)
get_cost_and_latency()
property kif: tuple[bool, int, int]
max_of(other)
min_of(other)
msb_mux(a: FixedVariable, b: FixedVariable, qint: tuple[Decimal, Decimal, Decimal] | None = None)
property qint: QInterval
quantize(k: int | bool, i: int, f: int, overflow_mode: str = 'WRAP', round_mode: str = 'TRN')
relu(i: int | None = None, f: int | None = None, round_mode: str = 'TRN')
property unscaled
class da4ml.trace.fixed_variable.FixedVariableInput(latency: float | None = None, hwconf=(-1, -1, -1))

Bases: FixedVariable

max_of(other)
min_of(other)
quantize(k: int | bool, i: int, f: int, overflow_mode: str = 'WRAP', round_mode: str = 'TRN')
relu(*args, **kwargs)
class da4ml.trace.fixed_variable.HWConfig(adder_size, carry_size, latency_cutoff)

Bases: NamedTuple

adder_size: int

Alias for field number 0

carry_size: int

Alias for field number 1

latency_cutoff: float

Alias for field number 2

da4ml.trace.fixed_variable.to_csd_powers(x: float) Generator[float, None, None]

da4ml.trace.fixed_variable_array module

class da4ml.trace.fixed_variable_array.FixedVariableArray(vars: ndarray[tuple[int, ...], dtype[_ScalarType_co]], solver_options: dict[str, Any] | None = None)

Bases: object

property dtype
flatten()
classmethod from_kif(k: ndarray[tuple[int, ...], dtype[bool | integer]], i: ndarray[tuple[int, ...], dtype[integer]], f: ndarray[tuple[int, ...], dtype[integer]], hwconf: HWConfig, latency: ndarray[tuple[int, ...], dtype[floating]] | float = 0.0, solver_options: dict[str, Any] | None = None)
classmethod from_lhs(low: ndarray[tuple[int, ...], dtype[floating]], high: ndarray[tuple[int, ...], dtype[floating]], step: ndarray[tuple[int, ...], dtype[floating]], hwconf: HWConfig, latency: ndarray | float = 0.0, solver_options: dict[str, Any] | None = None)
property kif
property ndim
quantize(k: ndarray[tuple[int, ...], dtype[integer]] | integer | int | None = None, i: ndarray[tuple[int, ...], dtype[integer]] | integer | int | None = None, f: ndarray[tuple[int, ...], dtype[integer]] | integer | int | None = None, overflow_mode: str = 'WRAP', round_mode: str = 'TRN')
ravel()
relu(i: ndarray[tuple[int, ...], dtype[integer]] | None = None, f: ndarray[tuple[int, ...], dtype[integer]] | None = None, round_mode: str = 'TRN')
reshape(shape)
property shape
property size
transpose(axes=None)
class da4ml.trace.fixed_variable_array.FixedVariableArrayInput(shape: tuple[int, ...] | int, hwconf: HWConfig = (1, -1, -1), solver_options: dict[str, Any] | None = None, latency=0.0)

Bases: FixedVariableArray

da4ml.trace.fixed_variable_array.to_raw_arr(obj: T) T

da4ml.trace.pipeline module

da4ml.trace.pipeline.retime_pipeline(csol: CascadedSolution, verbose=True)
da4ml.trace.pipeline.to_pipeline(sol: Solution, latency_cutoff: float, retiming=True, verbose=True) CascadedSolution

Split the record into multiple stages based on the latency of the operations. Only useful for HDL generation.

Parameters:
  • sol (Solution) – The solution to be split into multiple stages.

  • latency_cutoff (float) – The latency cutoff for splitting the operations.

  • retiming (bool) – Whether to retime the solution after splitting. Default is True. If False, new stages are created when the propagation latency exceeds the cutoff. If True, after the first round of splitting, the solution is retimed balance the delay within each stage.

  • verbose (bool) – Whether to print the actual cutoff used for splitting. Only used if rebalance is True. Default is True.

Returns:

The cascaded solution with multiple stages.

Return type:

CascadedSolution

da4ml.trace.tracer module

da4ml.trace.tracer.comb_trace(inputs: Sequence[FixedVariable], outputs: Sequence[FixedVariable]) Solution
da4ml.trace.tracer.comb_trace(inputs: FixedVariableArray, outputs: FixedVariableArray) Solution
da4ml.trace.tracer.gather_variables(inputs: Sequence[FixedVariable], outputs: Sequence[FixedVariable])

Module contents

class da4ml.trace.FixedVariableArray(vars: ndarray[tuple[int, ...], dtype[_ScalarType_co]], solver_options: dict[str, Any] | None = None)

Bases: object

property dtype
flatten()
classmethod from_kif(k: ndarray[tuple[int, ...], dtype[bool | integer]], i: ndarray[tuple[int, ...], dtype[integer]], f: ndarray[tuple[int, ...], dtype[integer]], hwconf: HWConfig, latency: ndarray[tuple[int, ...], dtype[floating]] | float = 0.0, solver_options: dict[str, Any] | None = None)
classmethod from_lhs(low: ndarray[tuple[int, ...], dtype[floating]], high: ndarray[tuple[int, ...], dtype[floating]], step: ndarray[tuple[int, ...], dtype[floating]], hwconf: HWConfig, latency: ndarray | float = 0.0, solver_options: dict[str, Any] | None = None)
property kif
property ndim
quantize(k: ndarray[tuple[int, ...], dtype[integer]] | integer | int | None = None, i: ndarray[tuple[int, ...], dtype[integer]] | integer | int | None = None, f: ndarray[tuple[int, ...], dtype[integer]] | integer | int | None = None, overflow_mode: str = 'WRAP', round_mode: str = 'TRN')
ravel()
relu(i: ndarray[tuple[int, ...], dtype[integer]] | None = None, f: ndarray[tuple[int, ...], dtype[integer]] | None = None, round_mode: str = 'TRN')
reshape(shape)
property shape
property size
transpose(axes=None)
class da4ml.trace.FixedVariableArrayInput(shape: tuple[int, ...] | int, hwconf: HWConfig = (1, -1, -1), solver_options: dict[str, Any] | None = None, latency=0.0)

Bases: FixedVariableArray

class da4ml.trace.HWConfig(adder_size, carry_size, latency_cutoff)

Bases: NamedTuple

adder_size: int

Alias for field number 0

carry_size: int

Alias for field number 1

latency_cutoff: float

Alias for field number 2

da4ml.trace.comb_trace(inputs, outputs)
da4ml.trace.to_pipeline(sol: Solution, latency_cutoff: float, retiming=True, verbose=True) CascadedSolution

Split the record into multiple stages based on the latency of the operations. Only useful for HDL generation.

Parameters:
  • sol (Solution) – The solution to be split into multiple stages.

  • latency_cutoff (float) – The latency cutoff for splitting the operations.

  • retiming (bool) – Whether to retime the solution after splitting. Default is True. If False, new stages are created when the propagation latency exceeds the cutoff. If True, after the first round of splitting, the solution is retimed balance the delay within each stage.

  • verbose (bool) – Whether to print the actual cutoff used for splitting. Only used if rebalance is True. Default is True.

Returns:

The cascaded solution with multiple stages.

Return type:

CascadedSolution