コード例 #1
0
 def jacfun(*args, **kwargs):
     start_node, end_nodes, tape = forward_pass(list_fun, args, kwargs,
                                                argnum)
     grads = list(
         map(partial(backward_pass, start_node, tape=tape), end_nodes))
     shape = dummy.outshape + getshape(args[argnum])
     return np.reshape(concatenate(grads), shape) if shape else grads[0]
コード例 #2
0
 def jacfun(*args, **kwargs):
     start_node, end_nodes, tape = forward_pass(list_fun, args, kwargs,
                                                argnum)
     run = partial(backward_pass, start_node, tape=tape, preserve_tape=True)
     grads = [run(end_node) for end_node in end_nodes]
     del tape[:]
     shape = dummy.outshape + getshape(args[argnum])
     return np.reshape(concatenate(grads), shape) if shape else grads[0]
コード例 #3
0
def time_fan_out_fan_in_forward_pass():
    if MASTER_BRANCH:
        forward_pass(fan_out_fan_in, (2.,), {})
    else:
        start_node = VJPNode.new_root()
        trace(start_node, fan_out_fan_in, x)
コード例 #4
0
def time_long_forward_pass():
    if MASTER_BRANCH:
        forward_pass(f_long, (2.,), {})
    else:
        start_node = VJPNode.new_root()
        trace(start_node, f_long, x)
コード例 #5
0
def time_exp_call():
    onp.exp(2.)

def time_exp_primitive_call_unboxed():
    np.exp(2.)

def time_exp_primitive_call_boxed():
    if MASTER_BRANCH:
        np.exp(progenitor)
    else:
        np.exp(start_box)

def time_no_autograd_control():
    # Test whether the benchmarking machine is running slowly independent of autograd
    A = np.random.randn(200, 200)
    np.dot(A, A)

if MASTER_BRANCH:
    short_start_node, short_end_node = forward_pass(f_short, (2.,), {})
    long_start_node, long_end_node = forward_pass(f_long, (2.,), {})
    fan_start_node, fan_end_node = forward_pass(fan_out_fan_in, (2.,), {})
    progenitor = new_progenitor(2.)
else:
    x = 2.
    start_node = VJPNode.new_root()
    start_box = new_box(x, 0, start_node)
    _, short_end_node = trace(VJPNode.new_root(), f_short, x)
    _, long_end_node  = trace(VJPNode.new_root(), f_long, x)
    _, fan_end_node   = trace(VJPNode.new_root(), fan_out_fan_in, x)
コード例 #6
0
 def jacfun(*args, **kwargs):
     start_node, end_nodes, tape = forward_pass(list_fun, args, kwargs, argnum)
     grads = list(map(partial(backward_pass, start_node, tape=tape), end_nodes))
     shape = dummy.outshape + getshape(args[argnum])
     return np.reshape(concatenate(grads), shape) if shape else grads[0]
コード例 #7
0
def time_long_forward_pass():
    core.forward_pass(f_long, (2., ), {})
コード例 #8
0
def time_fan_out_fan_in_forward_pass():
    core.forward_pass(fan_out_fan_in, (2., ), {})
コード例 #9
0
ファイル: bench_core.py プロジェクト: HIPS/autograd
def time_fan_out_fan_in_forward_pass():
    if MASTER_BRANCH:
        forward_pass(fan_out_fan_in, (2.,), {})
    else:
        start_node = VJPNode.new_root(x)
        trace(start_node, fan_out_fan_in, x)
コード例 #10
0
def time_short_forward_pass():
    core.forward_pass(f_short, (2., ), {})
コード例 #11
0
ファイル: bench_core.py プロジェクト: HIPS/autograd
def time_long_forward_pass():
    if MASTER_BRANCH:
        forward_pass(f_long, (2.,), {})
    else:
        start_node = VJPNode.new_root(x)
        trace(start_node, f_long, x)
コード例 #12
0
ファイル: bench_core.py プロジェクト: HIPS/autograd
def time_exp_call():
    onp.exp(2.)

def time_exp_primitive_call_unboxed():
    np.exp(2.)

def time_exp_primitive_call_boxed():
    if MASTER_BRANCH:
        np.exp(progenitor)
    else:
        np.exp(start_box)

def time_no_autograd_control():
    # Test whether the benchmarking machine is running slowly independent of autograd
    A = np.random.randn(200, 200)
    np.dot(A, A)

if MASTER_BRANCH:
    short_start_node, short_end_node = forward_pass(f_short, (2.,), {})
    long_start_node, long_end_node = forward_pass(f_long, (2.,), {})
    fan_start_node, fan_end_node = forward_pass(fan_out_fan_in, (2.,), {})
    progenitor = new_progenitor(2.)
else:
    x = 2.
    start_node = VJPNode.new_root(x)
    start_box = new_box(x, 0, start_node)
    _, short_end_node = trace(VJPNode.new_root(x), f_short, x)
    _, long_end_node  = trace(VJPNode.new_root(x), f_long, x)
    _, fan_end_node   = trace(VJPNode.new_root(x), fan_out_fan_in, x)
コード例 #13
0
ファイル: bench_core.py プロジェクト: RaoJun06/autograd
def time_short_forward_pass():
    core.forward_pass(f_short, (2.,), {})
コード例 #14
0
ファイル: bench_core.py プロジェクト: RaoJun06/autograd
def time_fan_out_fan_in_forward_pass():
    core.forward_pass(fan_out_fan_in, (2.,), {})
コード例 #15
0
ファイル: bench_core.py プロジェクト: RaoJun06/autograd
def time_long_forward_pass():
    core.forward_pass(f_long, (2.,), {})