Esempio n. 1
0
                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))
                toc = time()
                runtime_algopy_push_forward = toc - tic

                # compute pullback
                Qbar = UTPM(
                    numpy.ascontiguousarray(Qbar_data[0, ...].transpose(
                        (3, 2, 0, 1))))
                Rbar = UTPM(
                    numpy.ascontiguousarray(Rbar_data[0, ...].transpose(
                        (3, 2, 0, 1))))
                tic = time()
                Q, R = UTPM.qr(A)
                Abar = UTPM.pb_qr(Qbar, Rbar, A, Q, R)
                toc = time()
                runtime_algopy_pullback = toc - tic
Esempio n. 2
0
                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))
                toc = time()
                runtime_algopy_push_forward = toc - tic

                # compute pullback
                Qbar = UTPM(numpy.ascontiguousarray(Qbar_data[0,...].transpose((3,2,0,1))))
                Rbar = UTPM(numpy.ascontiguousarray(Rbar_data[0,...].transpose((3,2,0,1))))
                tic = time()
                Q,R = UTPM.qr(A)
                Abar = UTPM.pb_qr(Qbar, Rbar, A, Q, R)
                toc = time()
                runtime_algopy_pullback = toc - tic

                push_forward_ratio = runtime_algopy_push_forward/runtime_pyadolc_push_forward
                pullback_ratio = runtime_algopy_pullback/runtime_pyadolc_pullback
                print 'relative runtime of the push forward: algopy/pyadolc =', push_forward_ratio