Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 8c5629b

Browse files
author
Jules Pondard
committed
Add two files to generate and test options of the Genetic algorithm
generate_genetic_options will save a file containg the best found options by the genetic algorithm. eval_genetic_options would benchmark these options from the file.
1 parent 58caf8a commit 8c5629b

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import tensor_comprehensions as tc
2+
import tensor_comprehensions.tclib as tclib
3+
#import ipdb
4+
cache = tc.MappingOptionsCache("genetic_savedopt_conv_default.txt")
5+
import my_utils
6+
tc_code, tc_name, inp, init_input_sz = my_utils.get_convolution_example()
7+
my_utils.computeCat(inp)
8+
my_utils.set_tc(tc_code, tc_name)
9+
print("divs : " +str(my_utils.getAllDivs(inp)))
10+
tup = cache.load(tc_code, tc_name, inp, 1)
11+
if(tup == []):
12+
exit()
13+
best_options, = tup
14+
best_options = best_options.getDict()
15+
optsVect = my_utils.getRawVectorFromTcOpt(best_options)
16+
#optsVect = my_utils.catVec_to_optVec(optsVect)
17+
opts = my_utils.optionsFromVector(optsVect)
18+
print(opts)
19+
20+
tc_prog = tc.compile(tc_code, tc_name, opts, *inp)
21+
time = my_utils.evalTime(opts, estimator="median")
22+
print(time)
23+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import numpy as np
2+
#import ipdb
3+
import torch
4+
import tensor_comprehensions as tc
5+
6+
import my_utils
7+
8+
tc_code, tc_name, inp, init_input_sz = my_utils.get_default_convolution_example()
9+
my_utils.computeCat(inp)
10+
my_utils.set_tc(tc_code, tc_name)
11+
#config = tc.autotuner_settings
12+
#config["pop_size"]=50
13+
#config["generations"]=1
14+
15+
opts = tc.MappingOptions("naive")
16+
print(opts)
17+
18+
tc.autotune(tc_code, tc_name, *inp, starting_options=opts, cache_filename="genetic_savedopt_conv_default.txt", store_to_cache=True)

0 commit comments

Comments
 (0)