tensorflow / tensorflow/java

Functional API: Execution environment agnostic function

Offen
#205 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Java
Sterne
928
Forks
227
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit ConcreteFunction und den in der Issue genannten nativen TF_Function-, TF_GraphCopyFunction- und TFE_ContextAddFunction-APIs; vergleiche, wie die Ausführung im Eager- und im Graph-Modus dargestellt wird. Lies den Kontext zu #181 und #179, bevor du den Umfang festlegst. Als fertig sollte die vereinbarte Function-Abstraktion, die Spezialisierung auf Shape und dtype, der Umgang mit Variablen sowie das Verhalten des Graph-Zustands abgedeckt sein.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java, tensorflow
Bereich
backend-api-design, machine-learning
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.