diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2017-02-08 11:36:30 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-02-08 11:47:59 -0800 |
commit | f006837ce07c4db3923ac540418c5afe166dac0b (patch) | |
tree | 477b9ed5ac96c80198f363b3925da06c5c72498c /tensorflow/g3doc | |
parent | 1b6eec550bba8088b5e8a0fdeba9867f9a367a33 (diff) |
Doc update to custom data reader how to.
Change: 146935831
Diffstat (limited to 'tensorflow/g3doc')
-rw-r--r-- | tensorflow/g3doc/how_tos/new_data_formats/index.md | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/tensorflow/g3doc/how_tos/new_data_formats/index.md b/tensorflow/g3doc/how_tos/new_data_formats/index.md index 4f66d6d140..254e1b39b7 100644 --- a/tensorflow/g3doc/how_tos/new_data_formats/index.md +++ b/tensorflow/g3doc/how_tos/new_data_formats/index.md @@ -96,8 +96,8 @@ are: To register the op, you will use a `REGISTER_OP` call defined in [`tensorflow/core/framework/op.h`](https://www.tensorflow.org/code/tensorflow/core/framework/op.h). Reader ops never take any input and always have a single output with type -`Ref(string)`. They should always call `SetIsStateful()`, and have a string -`container` and `shared_name` attrs. You may optionally define additional attrs +`resource`. They should have string `container` and `shared_name` attrs. +You may optionally define additional attrs for configuration or include documentation in a `Doc`. For examples, see [`tensorflow/core/ops/io_ops.cc`](https://www.tensorflow.org/code/tensorflow/core/ops/io_ops.cc), e.g.: @@ -106,11 +106,12 @@ e.g.: #include "tensorflow/core/framework/op.h" REGISTER_OP("TextLineReader") - .Output("reader_handle: Ref(string)") + .Output("reader_handle: resource") .Attr("skip_header_lines: int = 0") .Attr("container: string = ''") .Attr("shared_name: string = ''") .SetIsStateful() + .SetShapeFn(shape_inference::ScalarShape) .Doc(R"doc( A Reader that outputs the lines of a file delimited by '\n'. )doc"); @@ -165,8 +166,11 @@ REGISTER_KERNEL_BUILDER(Name("TextLineReader").Device(DEVICE_CPU), TextLineReaderOp); ``` -The last step is to add the Python wrapper. You will import -`tensorflow.python.ops.io_ops` in +The last step is to add the Python wrapper. You can either do this by +[compiling a dynamic +library](../../how_tos/adding_an_op/#building_the_op_library) +or, if you are building TensorFlow from source, adding to `user_ops.py`. +For the latter, you will import `tensorflow.python.ops.io_ops` in [`tensorflow/python/user_ops/user_ops.py`](https://www.tensorflow.org/code/tensorflow/python/user_ops/user_ops.py) and add a descendant of [`io_ops.ReaderBase`](https://www.tensorflow.org/code/tensorflow/python/ops/io_ops.py). @@ -183,7 +187,6 @@ class SomeReader(io_ops.ReaderBase): ops.NotDifferentiable("SomeReader") -ops.RegisterShape("SomeReader")(common_shapes.scalar_shape) ``` You can see some examples in @@ -192,10 +195,10 @@ You can see some examples in ## Writing an Op for a record format Generally this is an ordinary op that takes a scalar string record as input, and -so follow [the instructions to add an Op](../../how_tos/adding_an_op/index.md). You may -optionally take a scalar string key as input, and include that in error messages -reporting improperly formatted data. That way users can more easily track down -where the bad data came from. +so follow [the instructions to add an Op](../../how_tos/adding_an_op/index.md). +You may optionally take a scalar string key as input, and include that in error +messages reporting improperly formatted data. That way users can more easily +track down where the bad data came from. Examples of Ops useful for decoding records: |