昇腾社区首页
中文
注册

算子在线编译选项

功能简介

模型编译时,选择在线编译算子,还是选择使用已编译好的算子二进制文件。

使用方法

设置config时使用下列开关进行配置,“jit_compile”默认值为“auto”,当前仅支持配置为“auto”

import torchair as tng
config = tng.CompilerConfig()

# 算子在线编译选项配置
config.experimental_config.jit_compile = "auto"
npu_backend = tng.get_npu_backend(compiler_config=config)
...
model = Model()
model = torch.compile(model, backend=npu_backend, dynamic=False)

“auto”参数说明:

  • 针对静态shape网络,选择在线编译算子。
  • 针对动态shape网络,优先查找系统中已编译好的算子二进制,如果查找不到对应的二进制,再在线编译算子。