Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
echuraev committed Feb 1, 2023
1 parent a35988f commit 611a320
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/runtime/opencl/opencl_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <dmlc/memory_io.h>
#include <tvm/runtime/registry.h>

#include <fstream>
#include <string>
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -139,11 +138,13 @@ PackedFunc OpenCLModuleNode::GetFunction(const std::string& name,
const ObjectPtr<Object>& sptr_to_self) {
ICHECK_EQ(sptr_to_self.get(), this);
if (name == "__GetPreCompiledPrograms") {
return PackedFunc(
[sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv = this->GetPreCompiledPrograms(); });
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
*rv = this->GetPreCompiledPrograms();
});
} else if (name == "__SetPreCompiledPrograms") {
return PackedFunc(
[sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { this->SetPreCompiledPrograms(args[0]); });
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
this->SetPreCompiledPrograms(args[0]);
});
}
ICHECK_NE(name, symbol::tvm_module_main) << "Device function do not have main";
auto it = fmap_.find(name);
Expand Down Expand Up @@ -315,7 +316,8 @@ std::string OpenCLModuleNode::GetPreCompiledPrograms() {
dmlc::MemoryStringStream writer(&data);
dmlc::Stream* strm = &writer;
strm->Write(static_cast<uint64_t>(parsed_kernels_.size()));
for (auto& [name, source] : parsed_kernels_) {
for (auto& it : parsed_kernels_) {
std::string name = it.first;
cl::OpenCLThreadEntry* t = workspace_->GetThreadEntry();
int device_id = t->device.device_id;
t->kernel_table.resize(workspace_->num_registered_kernels);
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp-runtime/opencl/opencl_compile_to_bin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ TEST_F(OpenCLCompileBin, SourceVsBinaryCompilationPerf) {
module.InstallKernel(m_workspace, m_workspace->GetThreadEntry(), m_kernelNames[i], e);
}
Timestamp comp_end = std::chrono::high_resolution_clock::now();
auto get_pre_compiled_f = module.GetFunction("__GetPreCompiledPrograms", GetObjectPtr<Object>(&module));
auto get_pre_compiled_f =
module.GetFunction("__GetPreCompiledPrograms", GetObjectPtr<Object>(&module));
bytes = String(get_pre_compiled_f());
std::chrono::duration duration =
std::chrono::duration_cast<std::chrono::nanoseconds>(comp_end - comp_start);
Expand Down

0 comments on commit 611a320

Please sign in to comment.