sketchgraphs_models.torch_extensions.segment_pool

Classes

SegmentAvgPool1DLoop

SegmentMaxPool1DLoop

Functions

sketchgraphs_models.torch_extensions.segment_pool.segment_avg_pool1d(values, scopes)
sketchgraphs_models.torch_extensions.segment_pool.segment_avg_pool1d_backward(grad_output, scopes, input_length)

Backward pass for segmented average pooling.

sketchgraphs_models.torch_extensions.segment_pool.segment_avg_pool1d_loop(values, scopes)
sketchgraphs_models.torch_extensions.segment_pool.segment_avg_pool1d_scatter(values, scopes)
sketchgraphs_models.torch_extensions.segment_pool.segment_max_pool1d(values: torch.Tensor, scopes: torch.Tensor, return_indices=False)torch.Tensor

Computes the maximum value in each segment.

Parameters
  • values (torch.Tensor) – A 1-dimensional tensor.

  • scopes (torch.Tensor) – a 2-dimensional integer tensor representing segments. Each row of scopes represents a segment, which starts at scopes[i, 0], and has length scopes[i, 1].

Returns

A tensor representing the maximum value for each segment.

Return type

torch.Tensor

sketchgraphs_models.torch_extensions.segment_pool.segment_max_pool1d_backward(grad_output, scopes, max_indices, input_length)