7053e01281232b62746e7e607c2bda520f8e58ab,misc/calc_speed.py,,test_fast,#,17

Before Change



def test_fast(L, B, N, train=False):
    reset_seed()
    a = Variable(torch.randn(L, B, N).float().cuda())
    c = Variable(torch.zeros(B, N).float().cuda())
    cell = SRUCell(N, N, dropout=0, use_tanh=False).cuda()
    if train: cell.train()
    torch.cuda.synchronize()
    start = time.time()
    for i in range(T):
        out = cell(a, c)
        out[0].sum().backward()
    torch.cuda.synchronize()
    print ("test_fast: {:.6f}".format(
        (time.time()-start)/T
    ))

After Change



def test_fast(L, B, N, train=False):
    reset_seed()
    a = Variable(torch.randn(L, B, N).float().cuda()*0.1)
    c = Variable(torch.zeros(B, N).float().cuda())
    cell = SRUCell(N, N, dropout=0, use_tanh=False).cuda()
    if train: cell.train()
    torch.cuda.synchronize()
    start = time.time()
    tot = 0
    for i in range(T):
        out = cell(a, c)
        tot += out[0].data[-1,-1,-1]
        if train:
            cell.zero_grad()
            out[0].mean().backward()
    torch.cuda.synchronize()
    print ("test_fast: {:.6f}".format(
        (time.time()-start)/T
    ))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 13

Instances


Project Name: asappresearch/sru
Commit Name: 7053e01281232b62746e7e607c2bda520f8e58ab
Time: 2018-07-25
Author: tao@asapp.com
File Name: misc/calc_speed.py
Class Name:
Method Name: test_fast


Project Name: asappresearch/sru
Commit Name: 7053e01281232b62746e7e607c2bda520f8e58ab
Time: 2018-07-25
Author: tao@asapp.com
File Name: misc/calc_speed.py
Class Name:
Method Name: test_conv


Project Name: asappresearch/sru
Commit Name: 7053e01281232b62746e7e607c2bda520f8e58ab
Time: 2018-07-25
Author: tao@asapp.com
File Name: misc/calc_speed.py
Class Name:
Method Name: test_lstm