Skip to content
Merged
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
2 changes: 0 additions & 2 deletions include/taco/codegen/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class Module {
setJITTmpdir();
}

void reset();

/// Compile the source into a library, returning its full path
std::string compile();

Expand Down
9 changes: 0 additions & 9 deletions src/codegen/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ void Module::setJITLibname() {
libname[i] = chars[rand() % chars.length()];
}

void Module::reset() {
funcs.clear();
moduleFromUserSource = false;
header.str("");
header.clear();
source.str("");
source.clear();
}

void Module::addFunction(Stmt func) {
funcs.push_back(func);
}
Expand Down
5 changes: 4 additions & 1 deletion src/tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,10 @@ void TensorBase::compile(taco::IndexStmt stmt, bool assembleWhileCompute) {

content->assembleFunc = lower(stmtToCompile, "assemble", true, false);
content->computeFunc = lower(stmtToCompile, "compute", assembleWhileCompute, true);
content->module->reset();
// If we have to recompile the kernel, we need to create a new Module. Since
// the module we are holding on to could have been retrieved from the cache,
// we can't modify it.
content->module = make_shared<Module>();
content->module->addFunction(content->assembleFunc);
content->module->addFunction(content->computeFunc);
content->module->compile();
Expand Down
15 changes: 15 additions & 0 deletions test/tests-tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,18 @@ TEST(tensor, recompile) {
ASSERT_TRUE(c.needsCompile());
ASSERT_EQ(c.begin()->second, 42.0);
}

TEST(tensor, cache) {
auto dim = 2;
IndexVar i("i"), j("j");
Tensor<int> a("a", {dim, dim}, {Dense, Dense});
Tensor<int> b("b", {dim, dim}, {Dense, Dense});
Tensor<int> c("c", {dim, dim}, {Dense, Dense});
// Add a computation to the cache.
c(i, j) = a(i, j); c.evaluate();
// Add a new computation to the cache.
c(i, j) = a(i, j) + b(i, j); c.evaluate();
// The addition of the new computation shouldn't have affected the cache's
// ability to answer a request for the first query.
c(i, j) = a(i, j); c.evaluate();
}