From a71beda35493d23f83fe695b6c9350d42aa7edd9 Mon Sep 17 00:00:00 2001
From: Lianmin Zheng <mercy_zheng@sjtu.edu.cn>
Date: Thu, 7 Dec 2017 08:20:45 +0800
Subject: [PATCH] [CODEGEN] add callback post proc for opencl (#692)

---
 src/codegen/build_opencl.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/codegen/build_opencl.cc b/src/codegen/build_opencl.cc
index 51779d3f7..c4a53744d 100644
--- a/src/codegen/build_opencl.cc
+++ b/src/codegen/build_opencl.cc
@@ -16,6 +16,7 @@ namespace tvm {
 namespace codegen {
 
 runtime::Module BuildOpenCL(Array<LoweredFunc> funcs) {
+  using tvm::runtime::Registry;
   bool output_ssa = false;
   CodeGenOpenCL cg;
   cg.Init(output_ssa);
@@ -23,6 +24,10 @@ runtime::Module BuildOpenCL(Array<LoweredFunc> funcs) {
     cg.AddFunction(f);
   }
   std::string code = cg.Finish();
+
+  if (const auto* f = Registry::Get("tvm_callback_opencl_postproc")) {
+    code = (*f)(code).operator std::string();
+  }
 #if TVM_OPENCL_RUNTIME
   return OpenCLModuleCreate(code, "cl", ExtractFuncInfo(funcs));
 #else
-- 
GitLab