简体   繁体   English

TVM库中relay.build_module.build()后图和库参数的差异

[英]Difference in graph and library parameters after relay.build_module.build() in the TVM library

In the TVM library, when the _relay.build_module.build()_ is used, what is the output result both after relay.build and tvm.build在TVM库中,当使用_relay.build_module.build()_relay.buildtvm.build后的输出结果是什么

And what is the difference and need for two parameters as output - graph and library - which are later used to run the graph or create a graph runtime ?以及作为输出 - 图形和库 - 稍后用于运行图形或创建图形运行时的两个参数的区别和需要是什么?

For example in this code :例如在这段代码中:

opt_level = 3
target = tvm.target.cuda()
with relay.build_config(opt_level=opt_level):
    graph, lib, params = relay.build_module.build(
        net, target, params=params)

What are the outputs graph , lib ?什么是输出lib Can we use just one of them to generate a graph runtime or do we always have to use both of them like below :我们可以使用只是其中之一,以生成图形运行还是我们总是要使用这两者象下面这样:

# create random input
ctx = tvm.gpu()
data = np.random.uniform(-1, 1, size=data_shape).astype("float32")
# create module
module = graph_runtime.create(graph, lib, ctx)
# set input and parameters
module.set_input("data", data)
module.set_input(**params)
# run
module.run()
# get output
out = module.get_output(0, tvm.nd.empty(out_shape)).asnumpy()

To generate a graph runtime you always need both graph and lib .要生成图形运行时,您始终需要graphlib

  • graph : the execution graph in json format graph : json 格式的执行图
  • lib : the TVM module library of compiled functions specifically for this graph on the target hardware. lib : 目标硬件上专门为此图编译的 TVM 模块库。

In other words, graph tells the compiler how the layers are arranged;换句话说,告诉编译器层是如何排列的; lib specifies the function each layer implements. lib指定了每层实现的功能。

Source: https://docs.tvm.ai/tutorials/relay_quick_start.html#sphx-glr-tutorials-relay-quick-start-py来源: https : //docs.tvm.ai/tutorials/relay_quick_start.html#sphx-glr-tutorials-relay-quick-start-py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM