Dissecting tf.function to discover AutoGraph strengths and subtleties

Paolo Galeone

Data-Structures Machine-Learning New Features Software Design

AutoGraph is one of the most exciting new features of Tensorflow 2.0: it allows transforming a subset of Python syntax into its portable, high-performance and language agnostic graph representation bridging the gap between Tensorflow 1.x and the 2.0 release based on eager execution.

Using AutoGraph with the `@tf.fuction` decorator seems easy, but in practice, writing efficient and correctly graph-convertible code requires to know in detail how AutoGraph and tf.function work.

In particular, knowing how:

- A graph is created and when it is re-used;
- To deal with functions that create a state;
- To correctly use the Tensorflow `tf.Tensor` object instead of using the Python native types to speed-up the computation;

defines the minimum skill-set required to write correct graph-accelerable code.

The talk will guide you trough AutoGraph and `tf.function` highlighting all the peculiarities that are worth knowing to build the right skill-set.

Type: Talk (30 mins); Python level: Intermediate; Domain level: Advanced

Paolo Galeone

Zuru Tech Italy

Computer Engineer + Machine Learning & Computer Vision researcher + Google Developer Expert in Machine Learning.

In 2019 Google recognized his expertise awarding him with the title of Google Developer Expert (GDE) in Machine Learning. As a GDE he shares his passion for machine learning and the Tensorflow framework by blogging, speaking at conferences, contributing to OpenSouce projects, and answering questions on Stack Overflow.

He blogs on https://pgaleone.eu/ and does OpenSource on https://github.com/galeone