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

Commit 0cc685e

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 4fdadf5 commit 0cc685e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 utils
6+
tc_code, tc_name, inp, init_input_sz = utils.get_convolution_example()
7+
print("divs : " +str(utils.getAllDivs(inp)))
8+
tup = cache.load(tc_code, tc_name, inp, 1)
9+
if(tup == []):
10+
exit()
11+
best_options, = tup
12+
best_options = best_options.getDict()
13+
optsVect = utils.getRawVectorFromTcOpt(best_options)
14+
#optsVect = utils.catVec_to_optVec(optsVect)
15+
opts = utils.optionsFromVector(optsVect)
16+
print(opts)
17+
18+
tc_prog = tc.compile(tc_code, tc_name, opts, *inp)
19+
time = my_utils.evalTime(opts, estimator="median")
20+
print(time)
21+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import numpy as np
2+
#import ipdb
3+
import torch
4+
import tensor_comprehensions as tc
5+
6+
import utils
7+
8+
tc_code, tc_name, inp, init_input_sz = utils.get_convolution_example()
9+
#config = tc.autotuner_settings
10+
#config["pop_size"]=50
11+
#config["generations"]=1
12+
13+
opts = tc.MappingOptions("naive")
14+
print(opts)
15+
16+
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)