#---------------------------------------------- # STEP 1: # QR decomposition by Givens Rotations # using pyadolc for the differentiation #---------------------------------------------- A = A_data[:, :, 0, 0] # trace QR decomposition with adolc AP = AdolcProgram() AP.trace_on(1) aA = adouble(A) AP.independent(aA) aQ, aR = qr(aA) AP.dependent(aQ) AP.dependent(aR) AP.trace_off() for r in range(repetitions): A = A_data[:, :, 0, 0] # compute push forward 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]
#---------------------------------------------- # STEP 1: # QR decomposition by Givens Rotations # using pyadolc for the differentiation #---------------------------------------------- A = A_data[:,:,0,0] # trace QR decomposition with adolc AP = AdolcProgram() AP.trace_on(1) aA = adouble(A) AP.independent(aA) aQ, aR = qr(aA) AP.dependent(aQ) AP.dependent(aR) AP.trace_off() for r in range(repetitions): A = A_data[:,:,0,0] # compute push forward 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]
adolc.dependent(y) adolc.trace_off() end_time = time.time() time_trace_adolc = end_time - start_time # trace with PYADOLC.cgraph from adolc.cgraph import AdolcProgram start_time = time.time() ap = AdolcProgram() ap.trace_on(2) x = adolc.adouble(numpy.random.rand(N)) ap.independent(x) y = f(x) ap.dependent(y) ap.trace_off() end_time = time.time() time_trace_cgraph = end_time - start_time # time ALGOPY hos_forward x = UTP(numpy.random.rand(D, N)) start_time = time.time() for rep in range(reps): cg.pushforward([x]) end_time = time.time() time_hos_forward_algopy = end_time - start_time # time PYADOLC hos_forward x = numpy.random.rand(N) V = numpy.random.rand(N, D - 1)
y = f(x) adolc.dependent(y) adolc.trace_off() end_time = time.time() time_trace_adolc = end_time - start_time # trace with PYADOLC.cgraph from adolc.cgraph import AdolcProgram start_time = time.time() ap = AdolcProgram() ap.trace_on(2) x = adolc.adouble(numpy.random.rand(N)) ap.independent(x) y = f(x) ap.dependent(y) ap.trace_off() end_time = time.time() time_trace_cgraph = end_time - start_time # time ALGOPY hos_forward x = UTP(numpy.random.rand(D, N)) start_time = time.time() for rep in range(reps): cg.pushforward([x]) end_time = time.time() time_hos_forward_algopy = end_time - start_time # time PYADOLC hos_forward x = numpy.random.rand(N) V = numpy.random.rand(N, D - 1)