You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+58-1Lines changed: 58 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ the `dev` profile in your Maven command to use those artifacts instead of buildi
21
21
Modifying the native op generation code (not the annotation processor) or the JavaCPP configuration (not the abstract Pointers) will require a
22
22
complete build could be required to reflect the changes, otherwise `-Pdev` should be fine.
23
23
24
-
## JDK 16+
24
+
###JDK 16+
25
25
26
26
If you're using JDK 16+, you need to add some exports for the formatter plugin:
27
27
@@ -98,6 +98,63 @@ Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.0:tes
98
98
This is because the native code crashed (i.e. because of a segfault), and it should have created a dump file somewhere in the project that you can use
99
99
to tell what caused the issue.
100
100
101
+
## Upgrading TensorFlow Version
102
+
103
+
To upgrade the version of TensorFlow that is embedded within TensorFlow Java, please follow carefully these steps.
104
+
105
+
### Upgrading TensorFlow Runtime Library
106
+
107
+
You can upgrade the version of the TensorFlow library by updating the archive downloadeded in the Bazel
108
+
[workspace](https://github.com/tensorflow/java/blob/master/tensorflow-core/tensorflow-core-api/WORKSPACE#L19) at build time. Make sure to
109
+
update the `urls`, `sha256` and `strip_prefix` fields of the `org_tensorflow` archive rule to reflect the values for the new version.
110
+
111
+
### Ops Classification
112
+
113
+
After building with the version of TensorFlow, you might notice that a lot of new operations appeared in the `org.tensorflow.ops.core`
114
+
package of the [generated sources](https://github.com/tensorflow/java/tree/master/tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/op/core) of
115
+
the `tensorflow-core-api` module. Many of these ops must be reclassified manually after running this initial build.
116
+
117
+
The actual classification process is a bit arbitrary and based on the good jugement of the developer. The reason is that most ops in Python
118
+
are being wrapped by a higher-level API and therefore are left unclassified, while in Java they are exposed and can be used directly by
119
+
the users.
120
+
121
+
For classifying an op, a `api_def` proto must be added to the `tensorflow-core-api`[folder](https://github.com/tensorflow/java/tree/master/tensorflow-core/tensorflow-core-api/src/bazel/api_def)
122
+
for this purpose, redefining optionally its endpoints or its visibility.
123
+
124
+
Writing these protos and trying the guess the right location for each new operation can become a tedious job so an utility program called `java_api_import`
125
+
has been created to help you with this task. This utility is available under the `bazel-bin` folder of `tensorflow-core-api` after the
For each new operation detected (i.e. any operation that does not have a valid `api_def` proto yet), the utility will suggest you some possible
137
+
package names that can be a good match for its classification (unless a "perfect match" has been found in the Python code, in which case the utility
138
+
will automatically classify the op). It is also possible to enter manually the name of the package to use, and the package can have multiple levels (e.g. `linalg.sparse`). The utility
139
+
application will then take care to write the `api_def` proto for each operation classified.
140
+
141
+
Make sure to erase completely the generated source folder of the `tensorflow-core-api` module before rerunning the build so you can see
142
+
if your ops have been classified properly.
143
+
144
+
#### Ops Kernel Upgrade
145
+
146
+
Some operations might be just an upgrade of another existing operations. For instance, there are many version of the `BatchMatMul` kernel (V1, V2, V3...).
147
+
When you see that a new op is just an upgrade from another other one, make sure that the latest version has a valid endpoint and that all other
148
+
previous versions of this operation are marked as `VISIBILITY: SKIP`.
149
+
150
+
### Java Protos Classification
151
+
152
+
TensorFlow Java distributes a large number proto definitions found in the TensorFlow Runtime Library as Java classes. Again, new protos might not
153
+
be classified properly since they may be lacking the `option java_*` statements at the beginning of their definition. If you notice in the
154
+
[generated protos](https://github.com/tensorflow/java/tree/master/tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/proto) of the `tensorflow-core-api`
155
+
that some new proto classes seems to be in the wrong package, create a Bazel patch at this effect to add the missing options.
156
+
See [existing patches](https://github.com/tensorflow/java/blob/master/tensorflow-core/tensorflow-core-api/external/tensorflow-proto.patch) for examples.
0 commit comments