Beispiel #1
0
            print(
                'running runtime tests for A.shape = (D,P,N,N) = %d, %d, %d, %d'
                % (D, P, N, N))
            A_data = numpy.random.rand(N, N, P, D)
            Qbar_data = numpy.random.rand(1, N, N, P, D)
            Rbar_data = numpy.random.rand(1, N, N, P, D)

            #----------------------------------------------
            # 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])
Beispiel #2
0
    for nn,N in enumerate(N_list):
        for nd,D in enumerate(D_list):

            print 'running runtime tests for A.shape = (D,P,N,N) = %d, %d, %d, %d'%(D,P,N,N)
            A_data = numpy.random.rand(N,N,P,D)
            Qbar_data = numpy.random.rand(1,N,N,P,D)
            Rbar_data = numpy.random.rand(1,N,N,P,D)

            #----------------------------------------------
            # 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])
Beispiel #3
0
# trace with PYADOLC
start_time = time.time()
adolc.trace_on(1)
x = adolc.adouble(numpy.random.rand(N))
adolc.independent(x)
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()
Beispiel #4
0
# trace with PYADOLC
start_time = time.time()
adolc.trace_on(1)
x = adolc.adouble(numpy.random.rand(N))
adolc.independent(x)
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()