paperbot · PL 论文追踪

全部论文 待读 收藏

P2 TF-Coder: Program Synthesis for Tensor Manipulations

TF-Coder:面向张量操作的程序合成
TOPLAS 44(2)2022匹配度 3/10 · 该论文属于程序合成与机器学习框架工具的交叉,但与用户核心方向(静态分析用于 ML/Agentic 程序、LLM 改进静态分析/形式化验证、浮点程序分析、贝叶斯程序分析)无直接关系。它不涉及静态分析、LLM/Agent 或浮点/贝叶斯分析,仅作为 PL+ML 的早期工具工作有一定间接参考价值。引用 24 inbox
Kensen Shi, David Bieber, Rishabh Singh
crossref: 2026-09-10

AI 速览

一句话:提出 TF-Coder,用带模型引导的自底向上加权枚举搜索,从输入输出示例合成 TensorFlow 张量操作代码。

深度学习框架(如 TensorFlow、PyTorch)虽极大便利了模型开发,但其编程范式与传统显式循环、条件分支的命令式编程差异巨大,学习曲线陡峭。本文提出 TF-Coder,一个面向 TensorFlow 的按示例编程(programming by example)工具。其核心是自底向上的加权枚举搜索:通过基于值的等价表达式剪枝避免重复搜索,并利用灵活的类型与值过滤保证候选表达式满足 TensorFlow 库的各项约束;同时训练模型,从输入输出张量的特征以及任务的自然语言描述中预测可能用到的 TensorFlow 算子,从而在搜索中优先考虑相关操作。作者在 70 个真实世界任务上评估,TF-Coder 在 5 分钟内解决了其中 63 个,且有时比经验丰富的人类程序员更快找到更简洁的解法。

问题
在 TensorFlow 这类张量框架中编写代码与传统命令式编程差异很大,开发者难以根据期望的输入输出张量反推应使用的算子组合。
方法
采用自底向上的加权枚举搜索合成张量操作程序,用基于值的等价表达式剪枝与类型/值过滤缩小空间,并训练模型从张量特征和自然语言描述预测算子以指导搜索优先级。
评估
在 70 个真实世界的 TensorFlow 张量操作任务上测试,考察求解成功率与耗时,并与人类程序员的表现作对比。
原文摘要(Abstract)

The success and popularity of deep learning is on the rise, partially due to powerful deep learning frameworks such as TensorFlow and PyTorch, which make it easier to develop deep learning models. However, these libraries also come with steep learning curves, since programming in these frameworks is quite different from traditional imperative programming with explicit loops and conditionals. In this work, we present a tool called TF-Coder for programming by example in TensorFlow. TF-Coder uses a bottom-up weighted enumerative search, with value-based pruning of equivalent expressions and flexible type- and value-based filtering to ensure that expressions adhere to various requirements imposed by the TensorFlow library. We train models to predict TensorFlow operations from features of the input and output tensors and natural language descriptions of tasks to prioritize relevant operations during search. TF-Coder solves 63 of 70 real-world tasks within 5 minutes, sometimes finding simpler solutions in less time compared to experienced human programmers.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1616,
  title = {TF-Coder: Program Synthesis for Tensor Manipulations},
  author = {Kensen Shi and David Bieber and Rishabh Singh},
  journal = {ACM Transactions on Programming Languages and Systems},
  volume = {44},
  number = {2},
  year = {2022},
  doi = {10.1145/3517034}
}