对算子进行图模式编译时,可以选择不同的图遍历顺序。该功能主要面向推理场景。
设置config时使用下列开关进行配置,“topology_sorting_strategy”默认值为“DFS”。
import torch_npu import torchair as tng config = tng.CompilerConfig() # 图模式编译的遍历策略配置 config.experimental_config.topology_sorting_strategy = "DFS" npu_backend = tng.get_npu_backend(compiler_config=config) ... model = Model() model = torch.compile(model, backend=npu_backend, dynamic=False)
当前支持配置为"BFS"、"DFS"、"RDFS"、“StableRDFS”。