Below is my code, when I add my_own_pass.cc into the TVM project tvm/src/relay/transform and compile together with TVM source. there is no problem。 Problem happened when I only compile my_own_pass.cc into libpassrelay.so。 I can’t find problem in my code, please helo to take a look at my code. thx.
`#include <tvm/relay/analysis.h>
#include <tvm/relay/attrs/transform.h>
#include <tvm/relay/expr_functor.h>
#include <tvm/relay/interpreter.h>
#include <tvm/relay/op.h>
#include <tvm/relay/op_attr_types.h>
#include <tvm/relay/transform.h>
#include <tvm/runtime/container.h>
#include <tvm/runtime/ndarray.h>
#include <tvm/runtime/object.h>
namespace tvm {
namespace relay {
class ToolChain1 : public ExprVisitor {
public:
private:
std::unordered_map<Expr, bool, ObjectPtrHash, ObjectPtrEqual> memo_;
void VisitExpr_(const CallNode* call) final {
//memo_[GetRef<Tuple>(n)] = result;
ExprVisitor::VisitExpr_(call);
std::cout << "call happened " << std::endl;
std::cout << AsText(GetRef<Expr>(call), false, nullptr) << std::endl;
}
};
Expr ToolChainParse1(const Expr& expr, const IRModule& mod) {
ToolChain1().VisitExpr(expr);
return expr;
}
namespace transform {
Pass ToolChainParse1() {
runtime::TypedPackedFunc<Function(Function, IRModule, PassContext)> pass_func =
[=](Function f, IRModule m, PassContext pc) {
return Downcast<Function>(ToolChainParse1(f, m));
};
return CreateFunctionPass(pass_func, 2, "ToolChainParse1", {});
}
TVM_REGISTER_GLOBAL ("relay._transform.ToolChainParse1").set_body_typed(ToolChainParse1);
}
}
}
`