CINN
CINN copied to clipboard
Add cost model for fusion merge pass
Sometimes fusion may cause bad performance, such as elementwise + reduce、elementwise + broadast、recompute. To avoid this situation happens, we train a model to evaluate the kernels performance before fusion and after fusion. 训练模型: 构造模型,然后使用fusion pass进行fusion,并生成代码并在目标硬件上运行,收集运行的时间。 使用这些真是的数据,预估group生成代码的性能。我们并不直接为group的性能打分,而是将两个group的feature拼接起来,判断group之间性能的强弱。
关于构造训练数据: 训练数据可以来自现有的各种模型,也可以来自随机构造的子图,或者某些有意构造的子图。
预测模型: 实际fusion的时候, 我们需要评估fusion前和fusion后的group之间的性能,只需要使用predict接口进行预测。
Thanks for your contribution!