Exemplo n.º 1
0
def broadcast_to(children, attrs, odtype='float32'):
    # TODO(@jroesch) export broadcast to?
    data = children[0]
    shape = attrs.get_int_tuple('shape')
    array = numpy.zeros(shape).astype(odtype)
    rconst = relay.Constant(nd.array(array))
    return op.broadcast_to_like(data, rconst)
Exemplo n.º 2
0
def add_grad(orig, grad):
    from tvm.relay import op
    return [
        op.broadcast_to_like(grad, orig.args[0]),
        op.broadcast_to_like(grad, orig.args[1])
    ]
Exemplo n.º 3
0
def subtract_grad(orig, grad):
    from tvm.relay import op
    return [
        op.broadcast_to_like(grad, orig.args[0]),
        op.broadcast_to_like(op.negative(grad), orig.args[1])
    ]