paddlenlp/transformers/mpnet/modeling.py
def create_position_ids_from_input_ids(input_ids, padding_idx=1):
    """
    Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
    are ignored. This is modified from fairseq's `utils.make_positions`. :param paddle.Tensor x: :return paddle.Tensor:
    """
    mask = (input_ids != padding_idx).astype(paddle.int64)
    incremental_indices = paddle.cumsum(mask, axis=1).astype(mask.dtype) * mask
    return incremental_indices.astype(paddle.int64) + padding_idx

    Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
    are ignored. This is modified from fairseq's `utils.make_positions`. :param paddle.Tensor x: :return paddle.Tensor:
    
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
are ignored. This is modified from fairseq's `utils.make_positions`.
Replace non - padding symbols with their position numbers . Position numbers begin at padding_idx + 1 . Padding symbols are ignored . This is modified from fairseq ' s ` utils . make_positions ` .
def create_position_ids_from_input_ids(input_ids, padding_idx=1):
    mask = (input_ids != padding_idx).astype(paddle.int64)
    incremental_indices = paddle.cumsum(mask, axis=1).astype(mask.dtype) * mask
    return incremental_indices.astype(paddle.int64) + padding_idx
def create_position_ids_from_input_ids ( input_ids , padding_idx = 1 ) : mask = ( input_ids != padding_idx ) . astype ( paddle . int64 ) incremental_indices = paddle . cumsum ( mask , axis = 1 ) . astype ( mask . dtype ) * mask return incremental_indices . astype ( paddle . int64 ) + padding_idx
Replace non-padding symbols with their position numbers.
Replace non - padding symbols with their position numbers .
"""
    Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
    are ignored. This is modified from fairseq's `utils.make_positions`. :param paddle.Tensor x: :return paddle.Tensor:
    """
input_ids
padding_idx