Skip to content

Commit a1abe99

Browse files
...text exposed to open source public git repo...
Update OSS documentation at third_party/py/tensorflow_docs/g3doc/en/guide/create_op.md to recommend people to use type hints for op in custom gradient registration. See context in cl/556171713. PiperOrigin-RevId: 558238535
1 parent dfea136 commit a1abe99

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

site/en/guide/create_op.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ To incorporate your custom op you'll need to:
5555

5656
* Some familiarity with C++.
5757
* Must have installed the
58-
[TensorFlow binary](../../install), or must have
59-
[downloaded TensorFlow source](../../install/source.md),
58+
[TensorFlow binary](https://www.tensorflow.org/install), or must have
59+
[downloaded TensorFlow source](https://www.tensorflow.org/install/source),
6060
and be able to build it.
6161

6262
## Define the op interface
@@ -1380,6 +1380,13 @@ Note that at the time the gradient function is called, only the data flow graph
13801380
of ops is available, not the tensor data itself. Thus, all computation must be
13811381
performed using other tensorflow ops, to be run at graph execution time.
13821382

1383+
Add type hints when registering the custom gradient for an op type to make the
1384+
code more readable, debuggable, easier to maintain, and more robust through data
1385+
validation. For example, when taking an `op` as a parameter in a function,
1386+
specify that the gradient function will take an
1387+
<a href="https://www.tensorflow.org/api_docs/python/tf/Operation"><code>tf.Operation</code></a>
1388+
as its parameter type.
1389+
13831390
### Shape functions in C++
13841391

13851392
The TensorFlow API has a feature called "shape inference" that provides

0 commit comments

Comments
 (0)