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

Commit 0d41d7d

Browse files
Theodoros Theodoridisnicolasvasilache
authored andcommitted
Fix bug introduced by #259
PR #259 switched from TC function names to using whole TCs (canonicalized) as part of compilation cache keys. However, the final step of the autotuner, that is retrieving the best found options, was not updated and it used just the function name. As a result, an empty optional<CudaMappingOptions> was always returned.
1 parent 4229ac4 commit 0d41d7d

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

include/tc/autotuner/utils/utils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "tc/core/cuda/cuda.h"
2222
#include "tc/core/cuda/cuda_mapping_options.h"
2323
#include "tc/core/utils/dlpack.h"
24+
#include "tc/lang/tree.h"
2425

2526
#include <llvm/ADT/Optional.h>
2627

@@ -59,6 +60,8 @@ llvm::Optional<CudaMappingOptions> getBestOptions(
5960
const std::vector<const DLTensor*>& inputs,
6061
const std::vector<const DLTensor*>& outputs);
6162

63+
std::string canonicalTC(const lang::TreeRef& tc);
64+
6265
} // namespace autotune
6366
} // namespace tc
6467

src/autotuner/genetic_autotuner.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ llvm::Optional<CudaMappingOptions> GeneticAutotuner::tune(
186186

187187
CHECK_GT(inputs.size(), 0);
188188
return tc::autotune::getBestOptions(
189-
tcName, inputs.begin()->second, outputPtrs);
189+
canonicalTC(tcNameMap_.at(tcName)), inputs.begin()->second, outputPtrs);
190190
}
191191

192192
} // namespace detail

src/autotuner/utils/utils.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "tc/lang/canonicalize.h"
2424
#include "tc/lang/parser.h"
2525
#include "tc/lang/sema.h"
26-
#include "tc/lang/tree.h"
2726

2827
namespace tc {
2928
namespace autotune {
@@ -74,20 +73,18 @@ std::vector<OptionsWithMedianTime> getOptionsAndMedianRuntimes(
7473
return c;
7574
}
7675

77-
namespace {
7876
std::string canonicalTC(const lang::TreeRef& tc) {
7977
std::stringstream ss;
80-
ss << lang::canonicalize(tc);
78+
ss << lang::canonicalize(lang::Sema().checkFunction(tc));
8179
return ss.str();
8280
}
83-
} // namespace
8481

8582
std::vector<CudaMappingOptions> restoreCandidates(
8683
const lang::TreeRef& tc,
8784
const std::vector<const DLTensor*>& inputs,
8885
const std::vector<const DLTensor*>& outputs) {
89-
auto candidates = getOptionsAndMedianRuntimes(
90-
canonicalTC(lang::Sema().checkFunction(tc)), inputs, outputs);
86+
auto candidates =
87+
getOptionsAndMedianRuntimes(canonicalTC(tc), inputs, outputs);
9188
LOG_IF(INFO, candidates.size() < FLAGS_tuner_gen_restore_number)
9289
<< "Requested " << FLAGS_tuner_gen_restore_number
9390
<< " candidates but there are only " << candidates.size() << " in cache.";

0 commit comments

Comments
 (0)