Any way to extract tir function from relay?

@Wheest for exmaple, build the relay, and the relay trans to relay ir.

first to get lib.

    with tvm.transform.PassContext(opt_level=3):
        lib = relay.build(mod_bert, target=target, params=params_bert)
    print(lib.ir_mod)

the ir contains below layer structure,

%22 = reshape(%21, newshape=[-1, 1024]) /* ty=Tensor[(256, 1024), float32] */;
%23 = cast(%bert.encoder.layer.attention.self.query.weight, dtype="float16") /* ty=Tensor[(1024, 1024), float16] */;

the tir func may like below

@tvmgen_default_fused_reshape_cast = primfn(args_7: handle, arg_type_ids_7: handle, num_args_7: int32, out_ret_value_7: handle, out_ret_tcode_7: handle, resource_handle_7: handle) -> int32

how can i get the tir func and feed other input, only test this kernel for some reason?

1 Like

I’m also interested in this. @chenugray , did you find a way to get the TIR from a Relay op?

Thanks!

1 Like

i wanna find way to automative single op accuracy testing. I use another way to extract single op ir definition, then run the single op ir func def. not using tir.

1 Like

me too.did you find a way to get the TIR from a Relay op? i use this interface

tec = relay.backend.te_compiler.get()

lower_module = tec.lower(opt_mode[“main”], “llvm”)

but get errors…

1 Like