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

Commit 56ccd32

Browse files
Jules PondardJules Pondard
authored andcommitted
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 3870fdb commit 56ccd32

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-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 utils
4+
5+
cache = tc.MappingOptionsCache("genetic_savedopt_conv_default.txt")
6+
7+
exptuner_config = utils.ExpTunerConfig()
8+
exptuner_config.set_convolution_tc()
9+
tc_code, tc_name, inp = exptuner_config.tc_code, exptuner_config.tc_name, exptuner_config.inp
10+
11+
print("divs : " + str(utils.getAllDivs(inp)))
12+
tup = cache.load(tc_code, tc_name, inp, 1)
13+
if(tup == []):
14+
exit()
15+
best_options, = tup
16+
best_options = best_options.getDict()
17+
optsVect = utils.getRawVectorFromTcOpt(best_options)
18+
opts = utils.optionsFromVector(optsVect)
19+
print(opts)
20+
21+
time = utils.evalTime(opts, exptuner_config, estimator="median")
22+
print(time)
23+
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 torch
3+
import tensor_comprehensions as tc
4+
5+
import utils
6+
7+
exptuner_config = utils.ExpTunerConfig()
8+
exptuner_config.set_convolution_tc()
9+
tc_code, tc_name, inp = exptuner_config.tc_code, exptuner_config.tc_name, exptuner_config.inp
10+
#config = tc.autotuner_settings
11+
#config["pop_size"]=50
12+
#config["generations"]=1
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)