I write code on C++ and I need to add another OpenCL code on top of TVM calculations without copying to the host memory in the middle. For that I want to get OpenCL context which is created here:
dev = DLDevice{kDLOpenCL, 0};
module = tvm::runtime::Module::LoadFromFile(filename);
gmod = module.GetFunction("default")(dev);
I see that OpenCLWorkspace in sources has it as class member. But in builded TVM this class is hidden in binaries as far as I understand.
I copied needed headers to ./include/tvm/runtime folder and did:
dev = DLDevice{kDLOpenCL, 0};
auto deviceAPI = tvm::runtime::DeviceAPI::Get(dev);
auto clWorkspace = dynamic_cast<tvm::runtime::cl::OpenCLWorkspace*>(deviceAPI);