tensorflow / tensorflow/java

Functional API: Execution environment agnostic function

未关闭
#205 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Java
星标
928
派生
227
PR 合并指标
30 天内没有已合并 PR

描述

cc @karllessard

This is somewhat of a sub-task of #181. The biggest pain I've ran into when using ConcreteFunction is that it only has tensor call methods, when it's mostly going to be used with Operand. This is a fairly simple issue on the surface. But, there's no way to execute ConcreteFunction in graph mode, i.e. if they are nested. The function used to generate the graph-mode outputs (which are wrapped in Signature) isn't saved. Now, it's easy enough to do this Java-side, in a sub class so that ConcreteFunction still supports loading. However, there's other issues such as supporting inputs with different shapes and dtypes that made me realize that what I'm trying to do here is closer to Python's Function and we may want to handle it with a new abstraction. There's also TF_Function and TF_GraphCopyFunction and TFE_ContextAddFunction which seems like it would allow attaching a ConcreteFunction to a graph without having to re-execute the builder in a new graph.

So I'd propose two things:

  • Implement Graph-mode and Eager-mode use of ConcreteFunctions using the native TF_Function APIs (the fact that the eager one doesn't mention gradients makes me a little worried, but I would think we can handle that manually later if necessary).
  • Add a Function class that acts like tf.function, in that it creates ConcreteFunctions as necessary for the argument shapes and dtypes. Additionally, since this will save the graph-creator lambda, we can have a debug flag that re-runs the lambda.

We also need to do something with variable handling, although that will probably need to wait on #179. Python seems to use an implicit variable-creation context to create them at the call-site and only allows it on the first call. I'd be fine with throwing errors and forcing the user to extract them, I think. I need to look into the details a bit more before I propose anything for this though. Variable scopes might be worth doing anyways for freezing, although hopefully explicit as part of Ops/Scope.

We'll need to pay attention to Graph states, like random seeds, too.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 issue 中提到的 ConcreteFunction 以及原生 TF_Function、TF_GraphCopyFunction 和 TFE_ContextAddFunction API 开始;比较 eager 执行和图模式执行的表示方式。在确定范围之前,先阅读相关的 #181 和 #179 上下文。完成内容应涵盖已达成共识的 Function 抽象、shape 和 dtype 特化、变量处理以及图状态行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, tensorflow
领域
backend-api-design, machine-learning
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。