BYOC codegen error

Now, I want to use a tf model to test BYOC and I met some problems. I think there some problems in dnnl/codegen.cc file

 void GenDNNLFunc(const Function& func) {
        CHECK(func.defined()) << "Input error: expect a Relay function.";
        const auto* call = func->body.as<CallNode>();
        CHECK(call) << "DNNL expects a single convolution or dense op";

        // Record the external symbol for runtime lookup.
        auto sid = GetExtSymbol(func);

        CodegenDNNL builder(sid);
        auto out = builder.VisitExpr(func->body);
        code_stream_ << builder.JIT(out);
      }

In this function, I think that not all func’s body is callNode. In my test model , some func’s body is tupleNode. So I change this function like this

void GenDNNLFunc(const Function& func) {
        CHECK(func.defined()) << "Input error: expect a Relay function.";
        if(func->body->IsInstance<TupleNode>()) {
            auto* tuple = func->body.as<TupleNode>();
            for(Expr field : tuple->fields) {
                LOG(INFO) << "wda debug : " << field;
                const auto* call = field.as<CallNode>();
            //if(call == NULL)
            //    return;
            CHECK(call) << "SSDNN expects a single convolution or dense op";
            }
        }else if(func->body->IsInstance<CallNode>()) {
    		const auto* call = func->body.as<CallNode>();
        	CHECK(call) << "DNNL expects a single convolution or dense op";
        	}
        // Record the external symbol for runtime lookup.
        auto sid = GetExtSymbol(func);

        CodegenDNNL builder(sid);
        builder.VisitExpr(func->body);
        code_stream_ << builder.JIT();
      
    }

I think this is also some problems. because this can not return a tuple. It can’t handle the following cases

def @dnnl_6(%dnnl_6_i0: Tensor[(1, 7, 7, 2048), float32], Inline=1, Compiler="dnnl", global_symbol="dnnl_6", Primitive=1) -> (Tensor[(1, 7, 7, 2048), float32], Tensor[(1, 7, 7, 2048), float32]) {
      %10 = nn.relu(%dnnl_6_i0) /* ty=Tensor[(1, 7, 7, 2048), float32] */;
      (%10, %10)
    }

@zhiics @comaniac @manupa-arm

I think this PR5320 will resolve the unnecessary tuple creation for your last case.

Right. We didn’t put TupleNode support in DNNL codegen because we was just using it for demonstration purpose. You are welcome to send a PR for it if that works for your case.

Thank you very much :grinning: