void tvmgen_default_imp_main_2_(int* imp_2_i0, int* imp_2_i1, int* out0) { int * buf_0 = (int *)std::malloc(4 * 4);
imp_binary_op(imp_2_i0, imp_2_i1, buf_0, 0, std::vector{2,2,}); memcpy(out0, buf_0, 4 * 4); free(buf_0); }
int tvmgen_default_imp_main_2_wrapper_(DLTensor* arg0, DLTensor* arg1, DLTensor* out0) { tvmgen_default_imp_main_2_((int*)(arg0->data), (int*)(arg1->data), (int*)(out0->data)); return 0; }
#ifdef _cplusplus extern “C” { #endif TVM_DLL int32_t tvmgen_default_imp_main_2(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code) { DLTensor* arg0 = (DLTensor*)(((TVMValue*)args)[0].v_handle); DLTensor* arg1 = (DLTensor*)(((TVMValue*)args)[1].v_handle); DLTensor* ret2 = (DLTensor*)(((TVMValue*)args)[2].v_handle); tvmgen_default_imp_main_2_wrapper(arg0,arg1,ret2); return 0; } #ifdef __cplusplus } #endif
this is the test code
import tvm
from tvm import te
import tvm.relay as relay
from tvm.contrib import cc, utils, graph_executor
from tvm.contrib.download import download_testdata
import os import numpy as np
/home/irfan/customTarget/C_imp_latest/tvm/customlibrary/libImp.so.2.2.0
import tvm from tvm.relay.op.contrib.register import register_pattern_table from tvm.relay.dataflow_pattern import is_op, wildcard import tvm from tvm import runtime from tvm import relay from tvm.relay import transform from collections import OrderedDict import numpy as np
target = “llvm -mtriple=aarch64-linux-gnu”
target_host = “llvm -mtriple=aarch64-linux-gnu”
dev = tvm.cpu(0)
def update_lib(lib): # Include the path of src/runtime/contrib/dnnl/dnnl.cc test_dir = os.path.dirname(os.path.realpath(os.path.expanduser(file))) source_dir = os.path.join(test_dir, “…”, “…”, “…”) contrib_path = os.path.join(source_dir, “src”, “runtime”, “contrib”)
# Setup the gcc flag to compile DNNL code.
kwargs = {}
kwargs["options"] = ["-O2", "-std=c++14", "-I" + contrib_path]
lib_path="/home/irfan/customTarget/C_imp_latest/tvm/compiled/lib.so"
# The generated C code with DNNL APIs is compiled to a binary lib.so.
lib.export_library(lib_path, fcompile=False, **kwargs)
return lib
num_r=2
num_c=5
a_np = np.random.choice(10, num_r*num_c).astype(“int32”).reshape((num_r, num_c))
b_np = np.random.choice(10, num_r*num_c).astype(“int32”).reshape((num_r, num_c))
c_np = np.random.choice(10, num_r*num_c).astype(“int32”).reshape((num_r, num_c))
d_np = np.add(a_np, b_np)
e_np = np.multiply(c_np, d_np)
w = relay.var(“w”, shape=a_np.shape, dtype=“int32”)
x = relay.var(“x”, shape=b_np.shape, dtype=“int32”)
z = relay.add(w, x)
func = relay.Function([w, x], z)
mod = tvm.IRModule.from_expr(func)
print(mod)
mod = relay.transform.AnnotateTarget([“imp”])(mod)
print(mod)
mod = relay.transform.InferType()(mod)
print(mod)
mod = relay.transform.PartitionGraph()(mod)
print(mod)
with tvm.transform.PassContext(opt_level=3, disabled_pass=[“AlterOpLayout”]):
lib = relay.build(mod, target=target, params=None)
print(lib.ir_mod)
update_lib(lib)
Here the relay.buidl works successfull but the text codegenrated by the external compiler not gettiing compile and continoucsly giving no known conversion