def test_modulo():
    x = mx.nd.ones(LARGE_X) * 6
    y = mx.nd.ones(LARGE_X) * 4
    z = (x % y)
    assert z[0] == 2
    assert z[-1] == 2
    x = mx.nd.ones(LARGE_X) * 5
    z = nd.modulo(x, y)
    assert z[0] == 1
    assert z[-1] == 1
Exemplo n.º 2
0
def getUniqueMatch(iou, min_threshold=1e-12):
    N, M = iou.shape
    iouf = iou.reshape((-1,))
    
    argmax = nd.argsort(iouf, is_ascend=False)
    argrow = nd.floor(nd.divide(argmax, M))
    argcol = nd.modulo(argmax, M)

    uniquel = set()
    uniquer = set()
    match = nd.ones((N,)) * -1
    i = 0
    while True:
        if argcol[i].asscalar() not in uniquel and argrow[i].asscalar() not in uniquer:
            uniquel.add(argcol[i].asscalar())
            uniquer.add(argrow[i].asscalar())
            if iou[argrow[i], argcol[i]] > min_threshold:
                match[argrow[i]] = argcol[i]
        if len(uniquel) == M or len(uniquer) == N:
            break
        i += 1
    return match.reshape((1,-1))
Exemplo n.º 3
0
def triangle(input):
    x = nd.abs(input[0])
    x_floor = nd.floor(x)
    x = nd.where(nd.modulo(x_floor, 2), 1 - x + x_floor, x - x_floor)
    return input[1] - x > 0
Exemplo n.º 4
0
 def triangle(x, y):
     x = nd.abs(x)
     x_floor = nd.floor(x)
     x = nd.where(nd.modulo(x_floor, 2), 1 - x + x_floor, x - x_floor)
     return y - x > 0