Documentation | Contributors | Community | Release Notes
Apache TVM is a compiler stack for deep learning systems. It is designed to close the gap between the productivity-focused deep learning frameworks, and the performance- and efficiency-focused hardware backends. TVM works with deep learning frameworks to provide end to end compilation to different backends.
© Contributors Licensed under an Apache-2.0 license.
import paddle
paddle.enable_static()
from tvm import relay
import tvm
import numpy as np
# 加载Paddle模型
place = paddle.CPUPlace()
exe = paddle.static.Executor(place)
[prog, feeds, outs] = paddle.static.load_inference_model('model/inference', exe)
# 将Paddle模型转为TVM Relay IR(Function and Parameters)
mod, params = relay.frontend.from_paddle(prog)
with tvm.transform.PassContext(opt_level=1):
intrp = relay.build_module.create_executor("graph", mod, tvm.cpu(0), 'llvm')
# 进行推理
input_data = np.random.rand(1, 3, 224, 224).astype('float32')
tvm_outputs = itrp.evaluate()(tvm.nd.array(input_data), **params).asnumpy()