VA = A_data[:, :, :, 1:] tic = time() out = AP.forward([A], [VA]) toc = time() runtime_pyadolc_push_forward = toc - tic adolc_Q = out[0][0] adolc_R = out[0][1] adolc_VQ = out[1][0] adolc_VR = out[1][1] # compute pullback WQ = Qbar_data WR = Rbar_data tic = time() out = AP.reverse([WQ, WR]) toc = time() runtime_pyadolc_pullback = toc - tic #---------------------------------------------- # STEP 2: # QR decomposition using LAPACK # using algopy for the differentiation #---------------------------------------------- # comute push forward A = UTPM( numpy.ascontiguousarray(A_data.transpose((3, 2, 0, 1)))) Q = UTPM(numpy.zeros((D, P, N, N))) R = UTPM(numpy.zeros((D, P, N, N))) tic = time()
VA = A_data[:,:,:,1:] tic = time() out = AP.forward([A],[VA]) toc = time() runtime_pyadolc_push_forward = toc - tic adolc_Q = out[0][0] adolc_R = out[0][1] adolc_VQ = out[1][0] adolc_VR = out[1][1] # compute pullback WQ = Qbar_data WR = Rbar_data tic = time() out = AP.reverse([WQ, WR]) toc = time() runtime_pyadolc_pullback = toc - tic #---------------------------------------------- # STEP 2: # QR decomposition using LAPACK # using algopy for the differentiation #---------------------------------------------- # comute push forward A = UTPM(numpy.ascontiguousarray(A_data.transpose((3,2,0,1)))) Q = UTPM(numpy.zeros((D,P,N,N))) R = UTPM(numpy.zeros((D,P,N,N))) tic = time() Q,R = UTPM.qr(A, out = (Q,R))
# time PYADOLC hov_reverse W = numpy.random.rand(1, 1, D) start_time = time.time() V = numpy.random.rand(N, P, D - 1) for rep in range(reps): for p in range(P): adolc.hos_forward(1, x, V[:, p, :], keep=D) adolc.hov_ti_reverse(1, W) end_time = time.time() time_hov_reverse_adolc = end_time - start_time # time PYADOLC.cgraph hov_reverse W = numpy.random.rand(1, 1, P, D) for rep in range(reps): ap.reverse([W]) end_time = time.time() time_hov_reverse_cgraph = end_time - start_time print "----------------" print time_trace_algopy print time_trace_adolc print time_trace_cgraph print "----------------" print time_hos_forward_algopy print time_hos_forward_adolc print time_hos_forward_cgraph print "----------------" print time_hov_forward_algopy print time_hov_forward_adolc print time_hov_forward_cgraph
# time PYADOLC hov_reverse W = numpy.random.rand(1, 1, D) start_time = time.time() V = numpy.random.rand(N, P, D - 1) for rep in range(reps): for p in range(P): adolc.hos_forward(1, x, V[:, p, :], keep=D) adolc.hov_ti_reverse(1, W) end_time = time.time() time_hov_reverse_adolc = end_time - start_time # time PYADOLC.cgraph hov_reverse W = numpy.random.rand(1, 1, P, D) for rep in range(reps): ap.reverse([W]) end_time = time.time() time_hov_reverse_cgraph = end_time - start_time print('----------------') print(time_trace_algopy) print(time_trace_adolc) print(time_trace_cgraph) print('----------------') print(time_hos_forward_algopy) print(time_hos_forward_adolc) print(time_hos_forward_cgraph) print('----------------') print(time_hov_forward_algopy) print(time_hov_forward_adolc) print(time_hov_forward_cgraph)