max.py 594 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
from .scatter import scatter
from .utils import gen_filled_tensor, gen_output


def scatter_max_(output, index, input, dim=0):
rusty1s's avatar
rusty1s committed
6
7
    """If multiple indices reference the same location, their **contribution
    maximize**.
rusty1s's avatar
rusty1s committed
8
9
10
11
12
13
14

    :rtype: (:class:`Tensor`, :class:`LongTensor`)
    """
    arg_output = gen_filled_tensor(index, output.size(), fill_value=-1)
    return scatter('max', dim, output, index, input, arg_output)


rusty1s's avatar
rename  
rusty1s committed
15
16
def scatter_max(index, input, dim=0, size=None, fill_value=0):
    output = gen_output(index, input, dim, size, fill_value)
rusty1s's avatar
rusty1s committed
17
    return scatter_max_(output, index, input, dim)