optimum/graphcore/modeling_utils.py
def forward(self, sequence, positions):
        """
        Gather the vectors at the specific positions over a batch.
        """
        num_classes = int(sequence.shape[1])
        one_hot_positions = F.one_hot(positions, num_classes)
        if self._is_half:
            one_hot_positions = one_hot_positions.half()
        else:
            one_hot_positions = one_hot_positions.float()
        return torch.matmul(one_hot_positions.detach(), sequence)

        Gather the vectors at the specific positions over a batch.
        
Gather the vectors at the specific positions over a batch.
Gather the vectors at the specific positions over a batch .
def forward(self, sequence, positions):
        num_classes = int(sequence.shape[1])
        one_hot_positions = F.one_hot(positions, num_classes)
        if self._is_half:
            one_hot_positions = one_hot_positions.half()
        else:
            one_hot_positions = one_hot_positions.float()
        return torch.matmul(one_hot_positions.detach(), sequence)
def forward ( self , sequence , positions ) : num_classes = int ( sequence . shape [ 1 ] ) one_hot_positions = F . one_hot ( positions , num_classes ) if self . _is_half : one_hot_positions = one_hot_positions . half ( ) else : one_hot_positions = one_hot_positions . float ( ) return torch . matmul ( one_hot_positions . detach ( ) , sequence )
Gather the vectors at the specific positions over a batch.
Gather the vectors at the specific positions over a batch .
"""
        Gather the vectors at the specific positions over a batch.
        """
self
sequence
positions