(input1,input2)
| 574 | return t2-t1,t3-t2 |
| 575 | |
| 576 | def test_DepthFlowProjectionModule(input1,input2): |
| 577 | # input1 = Variable(torch.zeros(12,3,64,64).type(torch.FloatTensor)) |
| 578 | # input2 = Variable(torch.rand(12,2,64,64).type(torch.FloatTensor)) |
| 579 | # input1 = Variable(torch.arange(0.0, 12*3*64*256).view(12,3,64,256), requires_grad=True) |
| 580 | # input2 = Variable(torch.rand(12,2,64,256)*20, requires_grad= True) |
| 581 | # input2 = Variable(torch.zeros(12,2,64,64)) |
| 582 | # input2 = Variable(torch.ones(12,2,64,64) * (-2.1)) |
| 583 | # input2 = Variable(torch.cat((torch.ones(12,1,64,64) *0.251, torch.zeros(12,1,64,64)),dim=1)) |
| 584 | # input1.data.uniform_() |
| 585 | # input2.data.uniform_(-5,5) |
| 586 | |
| 587 | # Project = DepthFlowProjectionModule() |
| 588 | |
| 589 | # t1 = time.time() |
| 590 | |
| 591 | # output = Project(input1,input2) |
| 592 | # t2 = time.time() |
| 593 | |
| 594 | # output.backward(output.data) |
| 595 | # t3 = time.time() |
| 596 | |
| 597 | |
| 598 | # print("CPU Forward and backward time is : " + str(t2-t1) +"s\t" + str(t3-t2) +"s\t") |
| 599 | |
| 600 | # |
| 601 | # print(output) |
| 602 | # print(input1.grad.size()) |
| 603 | # print(input1.grad) |
| 604 | # print(output[3,0,...]) |
| 605 | # temp = input1.grad |
| 606 | |
| 607 | # input1 = input1.cuda() |
| 608 | # input2 = input2.cuda() |
| 609 | # input1_cuda = Variable(torch.arange(0.0, 12*3*64*64).view(12,3,64,64).type(torch.cuda.FloatTensor), requires_grad=True) |
| 610 | # input2_cuda = Variable((torch.rand(12,2,64,64)*20).type(torch.cuda.FloatTensor), requires_grad= True) |
| 611 | input1_cuda = Variable(input1.data.type(torch.cuda.FloatTensor), requires_grad = True) |
| 612 | input2_cuda = Variable(input2.data.type(torch.cuda.FloatTensor), requires_grad = True) |
| 613 | Project = DepthFlowProjectionModule(input1_cuda.requires_grad) # regnenerate |
| 614 | t1 = time.time() |
| 615 | output_cuda = Project(input1_cuda,input2_cuda) |
| 616 | t2 = time.time() |
| 617 | output_cuda.backward(output_cuda.data) |
| 618 | t3 = time.time() |
| 619 | print("GPU Forward and backward time is : " + str(t2-t1) +"s\t" + str(t3-t2) +"s\t") |
| 620 | # print(output_cuda) |
| 621 | # print(input1_cuda.grad.size()) |
| 622 | # print(input1_cuda.grad) |
| 623 | |
| 624 | # print(output_cuda[3,0,...]) |
| 625 | # print(output[3,0,...]- output_cuda[3,0,...].cpu()) |
| 626 | |
| 627 | # print(output_cuda - output.cuda()) |
| 628 | # print(input1_cuda.grad - input1.grad.cuda()) |
| 629 | |
| 630 | |
| 631 | print("Check the forward path between CPU and GPU...",end='\t') |
| 632 | x = output_cuda - output.cuda() |
| 633 | # print(output_cuda[0, 0, :10, :10]) |
no test coverage detected