Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodiff benchmark #208

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/benchmark/run_all_autodiff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Running a suite of autodiff benchmarks.
python3 run_all_autodiff.py --logs=autodiff_logs.pkl 2> autodiff_logs.stderr
"""

import argparse
import subprocess
import utils


parser = argparse.ArgumentParser()
parser.add_argument('--logs', type=str)
args = parser.parse_args()

def run_single(case, n, d, r, R=None):
cmd = ['python3', 'run_single_autodiff.py', '--case=%s' % case,
'--n=%d' % n, '--d=%d' % d,
'--tt_rank_vec=%d' % r, '--logs=%s' % args.logs]
if R is not None:
cmd.append('--tt_rank_mat=%d' % R)
cmd.append('--m=%d' % n)
try:
print(' '.join(cmd))
print(subprocess.check_output(cmd))
except:
print('Running subprocess failed.')
pass


for n in [5, 10, 20]:
for d in [10, 20, 40]:
for r in [5, 10, 20, 40]:
run_single('completion', n, d, r)
run_single('ExpMachines', n, d, r)
for R in [5, 10, 20, 40]:
run_single('xAx', n, d, r, R)
run_single('xABx', n, d, r, R)
run_single('RayleighQuotient', n, d, r, R)
34 changes: 34 additions & 0 deletions docs/benchmark/run_single_autodiff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import argparse
import utils
import pickle
import os.path

parser = argparse.ArgumentParser()
parser.add_argument('--logs', type=str)
parser.add_argument('--case', type=str)
parser.add_argument('--m', type=int)
parser.add_argument('--n', type=int)
parser.add_argument('--d', type=int)
parser.add_argument('--tt_rank_mat', type=int)
parser.add_argument('--tt_rank_vec', type=int)
args = parser.parse_args()

if args.case == 'completion':
assert args.m is None and args.tt_rank_mat is None
case = utils.Completion(args.n, args.d, args.tt_rank_vec)
elif args.case == 'xAx':
case = utils.BilinearXAX(args.m, args.n, args.d, args.tt_rank_mat, args.tt_rank_vec)
elif args.case == 'xABx':
case = utils.BilinearXABX(args.m, args.n, args.d, args.tt_rank_mat, args.tt_rank_vec)
elif args.case == 'ExpMachines':
assert args.m is None and args.tt_rank_mat is None
case = utils.ExpMachines(args.n, args.d, args.tt_rank_vec)
elif args.case == 'RayleighQuotient':
case = utils.RayleighQuotient(args.m, args.n, args.d, args.tt_rank_mat, args.tt_rank_vec)
else:
print('Dont know this case.')

print(args.case, case.settings)
utils.benchmark(args.case, case, args.logs)


Loading