Skip to content

Add the Constant operator class - #11559

Merged
vrv merged 1 commit into
tensorflow:masterfrom
kbsriram:java-ops-1e-custom-constant
Jul 27, 2017
Merged

vrv merged 1 commit into
tensorflow:masterfrom
kbsriram:java-ops-1e-custom-constant

Conversation

@kbsriram

Copy link
Copy Markdown
Contributor

Create a custom operator class to create constants in the Graph,
and introduce the Operator marker annotation to identify
operator classes.

Please see #7149 for the master tracking issue.

@kbsriram
kbsriram requested a review from asimshankar as a code owner July 17, 2017 21:33
@tensorflow-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@asimshankar asimshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay. Some clarification questions, but otherwise looks good. Thanks!

import java.lang.annotation.Target;

/**
* Annotation used by classes that should be added to the Ops convenience API.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

Annotation used by classes to make TensorFlow operations conveniently accessible via org.tensorflow.ops.Ops

(or wherever this is supposed to make them accessible)

/**
* Annotation used by classes that should be added to the Ops convenience API.
*
* <p>An annotation processor builds the {@code Ops} API by aggregating all classes annotated as

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Instead of "Ops API", let's use "Ops class"?
(IIUC, these are for adding to the org.tensorflow.ops.Ops class, right?)

* <p>results in a method in the {@code Ops} API
*
* <pre>{@code
* ops.myOp(operand);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is ops? (Perhaps the sample should include a full snippet, including the import statements to make clear what ops is?

* ops.math().add(...);
* }</pre>
*/
String group() default "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions:

  1. Do we want to support multiple groups (e.g. math().tanh() and nn.tanh()?)
  2. Do we want to support nested namespaces, or just one level below ops?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like at least the generated wrapper classes and the few core custom ones would use single groups and one level. The second item seems potentially useful, but hadn't considered the first - that's an interesting idea.

In the interests of spacing out CLs - what do you think about beginning with supporting one group/one level, and adding support for these over time?

As an annotation definition, potentially we can change it incrementally (i.e. converting to an array to support multiple groups shouldn't change the syntax for existing single-group ops, though they would need to be recompiled. Supporting a naming convention like @group("contrib.mnist") might be the approach to provide nested namespaces, so that can work incrementally.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, only adding it later if and when we need it sounds good. Was just raising the question to think about (and also perhaps suggest that the AnnotationProcessor would want to ensure that there are no .s in the String returned by group() etc.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack - will do. I've corrected the other nits, and added a note in the annotation Javadoc that the names must be valid Java identifiers.

/**
* Annotation used by classes that should be added to the Ops convenience API.
*
* <p>An annotation processor builds the {@code Ops} API by aggregating all classes annotated as

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotation processor doesn't exist yet, right? It will come in a future PR? (Or am I missing something? :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in a future PR :-) I couldn't come up with a good way of documenting the intent of the annotation without referring to a yet-to-come processor. Suggestions? I'll insert a TODO in the javadoc to make it clear it doesn't exist yet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for now suffices :)

scope
.graph()
.opBuilder(OP, scope.makeOpName(OP))
.setAttr(VALUE, value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is the one and only place where the string constants are used, might as well inline them

@asimshankar asimshankar added the stat:awaiting response Status - Awaiting response from author label Jul 25, 2017
@kbsriram
kbsriram force-pushed the java-ops-1e-custom-constant branch from 5888075 to 679c7b9 Compare July 26, 2017 00:26
Create a custom operator class to create constants in the Graph,
and introduce the Operator marker annotation to identify
operator classes.

Please see tensorflow#7149 for the master tracking issue.
@kbsriram
kbsriram force-pushed the java-ops-1e-custom-constant branch from 679c7b9 to 8f051ba Compare July 26, 2017 14:10

@asimshankar asimshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@asimshankar

Copy link
Copy Markdown
Contributor

Jenkins, test this please

@asimshankar asimshankar added awaiting testing (then merge) and removed stat:awaiting response Status - Awaiting response from author labels Jul 26, 2017
@vrv
vrv merged commit 5991658 into tensorflow:master Jul 27, 2017
vrv pushed a commit to vrv/tensorflow that referenced this pull request Jul 28, 2017
END_PUBLIC

I dropped the following commit because it doesn't compile.
I will follow up with Andrew to fix it or revert it.
Commit 003deb8 authored by osdamv<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
Refactor and implementation of the camera API 1, it fixes tensorflow#8736 (tensorflow#10771)

List of commits in this CL:
---
Commit 4464503 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Use identity of param variable in cudnn_rnn.RNNParamsSaveable instead of parameter
variable directly. The RNNParamsSaveable is usually used in a graph which also
has a saver for the cudnn param variable itself, if the same op is used for
both, fails with a two savers for same op error.

PiperOrigin-RevId: 163431826

---
Commit d629a83 authored by RJ Ryan<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Increase bound on tf.contrib.signal.inverse_stft gradient error to avoid flakiness on macOS.

PiperOrigin-RevId: 163426631

---
Commit 253bcbb authored by Kay Zhu<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
[XLA] Use HloEvaluator for convolution in reference_util.

Also Speed up HloEvaluator's HandleConvolution in non-opt build, by moving calls
to HloInstruction::shape() out of the inner loop.

PiperOrigin-RevId: 163416183

---
Commit 569a00e authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Update API to traffic in unique_ptrs rather than owning raw pointers

PiperOrigin-RevId: 163414320

---
Commit 31a77bc authored by Asim Shankar<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Java: Update release to 1.3.0-rc1

PiperOrigin-RevId: 163413736

---
Commit 1ebbf43 authored by Jonathan Hseu<[email protected]>
Committed by GitHub<[email protected]>:
Add missing grpc dependency (tensorflow#11828)

---
Commit 905abb1 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Test asserts should have `expected` first.

PiperOrigin-RevId: 163409348

---
Commit d5cc143 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Increase timeout to deflake the test.

PiperOrigin-RevId: 163407824

---
Commit ce1c7f0 authored by Eli Bendersky<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Properly include logging header in xla_internal_test_main

PiperOrigin-RevId: 163405986

---
Commit 22241cd authored by joetoth<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
External leveldb link changed (tensorflow#11833)

table_format.txt was renamed to table_format.md
---
Commit 6b7314d authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Consolidating the code to fill the partition's function library
into one place. Previously, Partition() and MasterSession::RegisterPartition()
both fills in the partitioned graph's function library.

PiperOrigin-RevId: 163400992

---
Commit 28373cf authored by Frank Chen<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Adds preliminary support for Cloud TPUs with Cluster Resolvers. This aims to allow users to have a better experienec when specifying one or multiple Cloud TPUs for their training jobs by allowing users to use names rather than IP addresses.

PiperOrigin-RevId: 163393443

---
Commit e5353c9 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Don't prune nodes that have reference inputs.

PiperOrigin-RevId: 163390862

---
Commit 2265108 authored by Asim Shankar<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
C API: Groundwork for experimenting with TF_Tensor in device memory.

TF_Tensor objects are always backed by host memory. This commit lays
the groundwork for allowing TF_Tensor objects to refer to tensor data
on device (e.g., GPU) memory.

PiperOrigin-RevId: 163388079

---
Commit 613bf1c authored by Yuefeng Zhou<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
fix asan test failure in SingleMachineTest::ReleaseMemoryAfterDestruction.

PiperOrigin-RevId: 163386941

---
Commit 4653d37 authored by Eli Bendersky<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
[XLA] Change type to appease GPU builds.

PiperOrigin-RevId: 163384927

---
Commit 9f131bd authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Internal change

PiperOrigin-RevId: 163378484

---
Commit 8bc0236 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
PiperOrigin-RevId: 163366493

---
Commit 3b97f1f authored by Yangzihao Wang<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Change to only run one round of matmul benchmark.

PiperOrigin-RevId: 163364341

---
Commit a4a3a33 authored by Yun Peng<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
Fix ./configure on Windows (tensorflow#11775)

* Fix ./configure on Windows

* Disable bitwise_ops_test on Windows

---
Commit ae3119d authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Small changes to op framework.

PiperOrigin-RevId: 163361071

---
Commit f40189d authored by qjivy<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
PR again: Enable building label_image with jpeg/gif/png decoder for Android.  (tensorflow#11475)

* Enable building label_image with jpeg/gif/png decoder for Android.
Add dependency "android_tesnorflow_image_op" to label_image, which
is not overlapped with android_tensorflow_kernels.

* Running buildifier to reformat the BUILD files for
sanity check.

---
Commit 5991658 authored by KB Sriram<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
Add the Constant operator class (tensorflow#11559)

Create a custom operator class to create constants in the Graph,
and introduce the Operator marker annotation to identify
operator classes.

Please see tensorflow#7149 for the master tracking issue.
---
Commit 86ca350 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Further BUILD cleanup

PiperOrigin-RevId: 163360750

---
Commit 376bb06 authored by Pete Warden<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Look inside functions to see which node types are used.

PiperOrigin-RevId: 163360375

---
Commit 2139e7d authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
[tf.contrib.data] map expects a nested structure.

Fixes tensorflow#11786

PiperOrigin-RevId: 163359134

---
Commit d09304f authored by Jonathan Hseu<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
Upgrade gRPC (tensorflow#11768)

* BUILD rule modifications

* More build fixes

* Code changes

* More code fixes

* Working tests

* CMake build

* Fix pprof

* Fix header includes

* CMake fix test

* Bazel clean

* Fix verbs

* More verbs fixes

* bazel clean for XLA

* Windows build fix test

* Add openssl/rand.h

* New cmake build command

* --config Release

---
Commit 3cd8284 authored by David Norman<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
Fix error with default python path selection (tensorflow#11814)

* Fix error with default python path selection

* Move setting of environment var outside if / else

---
Commit ddd8e21 authored by Eli Bendersky<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
[XLA] Consolidate all similar main()s in tests into a single target.

PiperOrigin-RevId: 163354724

---
Commit a36bca2 authored by Tayo Oguntebi<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Remove ShapeWithoutPadding() utility function, as it is no longer needed.

PiperOrigin-RevId: 163353430

---
Commit b26f9cd authored by David Norman<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
Ensure that the multi-instruction fuse can take shared inputs (tensorflow#11748)

* Ensure that the multi-instruction fuse can take shared inputs

Note that the fuse action only works when the shared input / constant
appears after all of its consumers in the list of instructions.

* Add a comment describing the test

---
Commit 34cbf16 authored by Jiri Simsa<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Update Dataset API documentation.

PiperOrigin-RevId: 163349457

---
Commit 2381ce5 authored by Abdullah Alrasheed<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
DOC: Fix typo. (tensorflow#11813)

you could could be I/O bottlenecked.
TO:
you could be I/O bottlenecked.
---
Commit e4a5c53 authored by Toby Boyd<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
["Variable", "VariableV2", "VarHandleOp"] is the default for ps_ops=None

PiperOrigin-RevId: 163344629

---
Commit 722f6f3 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Fix TensorForest's saveable object names so loading a savedmodel works.

PiperOrigin-RevId: 163332598

---
Commit cda80a7 authored by Eric Liu<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
[tpu profiler] Dump HLO graphs in profile responses to the log directory.

PiperOrigin-RevId: 163318992

---
Commit cea9ef6 authored by horance<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
Refactoring device name utils (tensorflow#11797)

* remove duplicated code for full_name and legacy_name for DeviceNameUtils

* replace tabs

* Real->Device

---
Commit 1f7c0f9 authored by Kongsea<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
Refine docstrings (tensorflow#11800)

---
Commit dd1f0cd authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Supports lookup devices by fullname either in the canonical form or the
legacy form. This makes DeviceSet behaves the same as DeviceMgr's
FindDevice method.

PiperOrigin-RevId: 163300346

---
Commit 631a364 authored by Kay Zhu<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
[XLA] Add Reduce, DynamicSlice and DynamicSliceUpdate to HloEvaluator.

- Reduce is disabled explicitly for constant folding, as not all types of
embedded computation can be currently supported by the evaluator.

- Added support to evaluate HloModule to HloEvaluator.

- Minor signature change to Evaluate().

PiperOrigin-RevId: 163299238

---
Commit a524701 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Sets the incarnation number even when the attribute is set.

PiperOrigin-RevId: 163299121

---
Commit a49fe03 authored by Suharsh Sivakumar<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Remove platform bridge for grpc_response_reader.

PiperOrigin-RevId: 163295986

---
Commit 4404aa7 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
[XLA] Add TODO comment explaining why the IsScalar check exists.

PiperOrigin-RevId: 163292777

---
Commit 43036ac authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Remove unnecessary break statements.

PiperOrigin-RevId: 163291947

---
Commit fd5de46 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
[XLA] Add regression test for a corner case using Reduce that currently fails with the GPU backend.

PiperOrigin-RevId: 163287986

---
Commit 32e198f authored by Chris Leary<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
[TF:XLA] Add tf.cross support.

See tensorflow#11788

PiperOrigin-RevId: 163287731

---
Commit 88abddb authored by Alan Yee<[email protected]>
Committed by Vijay Vasudevan<[email protected]>:
Update README.md (tensorflow#11793)

Remove bad practices of sudo pip and install use safer pip install commands
---
Commit 9b30dc3 authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Remove final mentions of `get_shape` in docstring.

PiperOrigin-RevId: 163282839

---
Commit 423c1ee authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
BREAKING CHANGE: Fix semantic error in how maybe_batch* handles sparse tensors.

PiperOrigin-RevId: 163276613

---
Commit 6028c07 authored by Justin Lebar<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Highlight incoming/outgoing edges on hover in HLO graphviz dumps, and other improvements.

Other improvements:

 - Don't show tooltips for nodes and clusters.  Previously we'd show a
   tooltip containing a pointer value expressed as decimal.  Not so
   useful.

 - Show tooltips on edges with the to/from node names.

 - Fix bug wherein if we had

   - a node at the "edge" of the graph (so its operands aren't included
     unless they're referenced by another node),
   - with all of its operands included in the graph save one or more
     constants, and
   - those constants weren't referenced by any nodes not at the edge of
     the graph,

   we would incorrectly draw the node as "grayed out", indicating that
   one of its operands (namely, its constant operand) wasn't present in
   the graph.

   This is wrong because constants are inlined into their users, so they
   should always count as "displayed" for the purposes of determining
   whether a node is grayed out.

PiperOrigin-RevId: 163276108

---
Commit ce7a355 authored by Joshua V. Dillon<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Update contrib/distributions/estimator_test build dependency.

PiperOrigin-RevId: 163272464

---
Commit 1b8458a authored by A. Unique TensorFlower<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Shorten docstring line.

PiperOrigin-RevId: 163269709

---
Commit 69e323c authored by Asim Shankar<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Fix comment ypo

PiperOrigin-RevId: 163266376

---
Commit 08790e7 authored by Chris Leary<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
[XLA] Fix a bug in cloning outfeeds, carried the wrong shape.

PiperOrigin-RevId: 163265592

---
Commit 1bad826 authored by Yangzihao Wang<[email protected]>
Committed by TensorFlower Gardener<[email protected]>:
Rollback of GPU kernel implementation of transpose for tensors with one small dimension.
END_PUBLIC

BEGIN_PUBLIC
BEGIN_PUBLIC
Automated g4 rollback of changelist 162525519

PiperOrigin-RevId: 163490703
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants