grafx.render

compute_render_order(G_any, method='beam', **kwargs)

Computes a rendering order for the graph (in either type).

Parameters:
  • G_any (GRAFX or GRAFXTensor) – The graph to compute the rendering order. As the main computation is done with tensors, if a graph is provided, it will be internally converted to a GRAFXTensor object.

  • method (str, optional) – The method to use for computing the rendering order. Allows "greedy", "beam", "fixed", and "one-by-one". For the comparison of these methods, see this section (default: "beam").

  • **kwargs – Additional arguments for some methods. If method == "beam", width and depth can be optionally passed as arguments (default: 1 and 64, respectively). If method == "fixed", a sequence of node types must be passed with key fixed_order.

Returns:

A ndoe type sequence and a tensor that specifies the rendering order for each node.

Return type:

Tuple[List[str], LongTensor]

reorder_for_fast_render(G_any, method='beam', **kwargs)

Computes a rendering order for the graph (in either type) and reorders the graph for faster rendering. The former is done with compute_render_order().

Parameters:
  • G_any (GRAFX or GRAFXTensor) – The graph to compute the rendering order and reorder.

  • method (str, optional) – The ordering method. (default: "beam").

  • **kwargs – Additional arguments for some methods.

Returns:

A reordered graph.

Return type:

GRAFX or GRAFXTensor

class RenderData(method: str, num_nodes: int, max_order: int, siso_only: bool, iter_list: List[_SingleRenderData])

Holds all data necessary for rendering an audio processing graph.

Parameters:
  • method (str) – The overall rendering method.

  • num_nodes (int) – Total number of nodes in the graph.

  • max_order (int) – The maximum order of processing required.

  • siso_only (bool) – Indicates if the graph is strictly single-input and single-output.

  • iter_list (List[_SingleRenderData]) – List of rendering data for each processing stage.

prepare_render(G_t)

Computes the metadata, i.e., sequence of operations including the tensor reads, aggregations, processings, and writes, required for the graph rendering.

Parameters:

G_t (GRAFXTensor) – The graph to compute the metadata for rendering.

Returns:

The metadata required for rendering the graph.

Return type:

RenderData

render_grafx(processors, input_signals, per_type_parameters, render_data, common_parameters=None, parameters_grad=True, input_signal_grad=False)

Renders an audio graph using a specified processing method, handling both batched and non-batched inputs.

Parameters:
  • processors (Mapping) – Dictionary of audio processors, either in dict or nn.ModuleDict, where keys are the processor types and values are their processor objects.

  • input_signals (FloatTensor, \(|V_0| \times C \times L\) or \(B\times |V_0| \times C \times L\)) – Tensor of \(|V_0|\) input signals, either in three-dimensional or four-dimensional (i.e., with a batch axis) format.

  • per_type_parameters (Mapping) – Dictionary of parameters in dict, nn.ParameterDict or nn.ModuleDict. Each key is a processor type and each value is a single tensor or dictionary of tensors.

  • render_data (RenderData) – Metadata for rendering the graph.

  • common_parameters (optional) – A tensor or a dictionary of tensors for the parameter types that are common to all nodes. Hence, we expect each tensor’s first dimension size to be \(|V|\) (default: None).

  • parameters_grad (bool, optional) – Allow calculation of the parameter gradients; we can omit certain steps to save memory when set to False (default: True).

  • input_signal_grad (bool, optional) – Allow calculation of the input signal gradients; we can omit certain steps to save memory when set to False (default: False).

Returns:

Output audio signals of shape \(|V_N| \times C \times L\) or \(B\times |V_N| \times C \times L\), a list of intermediate tensors, and the signal buffer used for rendering, i.e., all the intermediate outputs, of shape \(|V| \times C \times L\) or \(B\times |V| \times C \times L\).

Return type:

Tuple[FloatTensor, list, FloatTensor]