1- /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2-
3- Licensed under the Apache License, Version 2.0 (the "License");
4- you may not use this file except in compliance with the License.
5- You may obtain a copy of the License at
6-
7- http://www.apache.org/licenses/LICENSE-2.0
8-
9- Unless required by applicable law or agreed to in writing, software
10- distributed under the License is distributed on an "AS IS" BASIS,
11- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- See the License for the specific language governing permissions and
13- limitations under the License.
14- ==============================================================================*/
15-
1+ /*
2+ Licensed under the Apache License, Version 2.0 (the "License");
3+ you may not use this file except in compliance with the License.
4+ You may obtain a copy of the License at
5+
6+ http://www.apache.org/licenses/LICENSE-2.0
7+
8+ Unless required by applicable law or agreed to in writing, software
9+ distributed under the License is distributed on an "AS IS" BASIS,
10+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+ See the License for the specific language governing permissions and
12+ limitations under the License.
13+ =======================================================================
14+ */
1615package org .tensorflow ;
1716
1817import static org .tensorflow .internal .c_api .global .tensorflow .TFE_ContextOptionsSetAsync ;
2928import org .tensorflow .internal .c_api .TFE_ContextOptions ;
3029import org .tensorflow .internal .c_api .TF_Status ;
3130import org .tensorflow .op .Op ;
32- import org .tensorflow .op .Ops ;
3331import org .tensorflow .op .Scope ;
3432import org .tensorflow .op .core .Assign ;
3533import org .tensorflow .op .core .Placeholder ;
@@ -114,7 +112,8 @@ public Options devicePlacementPolicy(DevicePlacementPolicy value) {
114112 * Configures the session based on the data found in the provided configuration.
115113 *
116114 * @param config a config protocol buffer
117- * @see <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/protobuf/config.proto">config.proto</a></a>
115+ * @see <a
116+ * href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/protobuf/config.proto">config.proto</a></a>
118117 */
119118 public Options config (ConfigProto config ) {
120119 this .config = config ;
@@ -321,17 +320,16 @@ TFE_Context nativeHandle() {
321320 /**
322321 * Attach the list of native resources to this eager session scope.
323322 *
324- * <p>When the eager session is closed (i.e. by calling {@link #close()} explicitly or
325- * implicitly via try-with-resources), all native resources attached to the session will be
326- * released as well, unless so other references are {@link Pointer#retainReference() retaining}
327- * them.</p>
323+ * <p>When the eager session is closed (i.e. by calling {@link #close()} explicitly or implicitly
324+ * via try-with-resources), all native resources attached to the session will be released as well,
325+ * unless so other references are {@link Pointer#retainReference() retaining} them.
328326 *
329327 * <p>Attached resources can still be garbage collected though if their associated {@link Pointer}
330328 * is no longer reachable in Java, independently of their reference count. Therefore, it is
331329 * assumed that these resources are not required by the native library once the Java client no
332- * longer needs them.</p>
330+ * longer needs them.
333331 *
334- * <p>Attaching a resource already attached to this session will have no effect.</p>
332+ * <p>Attaching a resource already attached to this session will have no effect.
335333 *
336334 * @param resources resources to attach to the session
337335 */
@@ -346,14 +344,14 @@ void attach(Pointer... resources) {
346344 * Detach a list of resources from this eager session scope.
347345 *
348346 * <p>Detached native resources will prevent them to be automatically released when the session is
349- * closed.</p>
347+ * closed.
350348 *
351349 * <p>Note though that this method will decrement the reference count of each resources being
352- * detached, which may automatically released them if that count reaches 0. Therefore,
353- * invoking {@link Pointer#retainReference()} prior to this call on any resource that must remain
354- * valid after being detached might be required.</p>
350+ * detached, which may automatically released them if that count reaches 0. Therefore, invoking
351+ * {@link Pointer#retainReference()} prior to this call on any resource that must remain valid
352+ * after being detached might be required.
355353 *
356- * <p>Detaching a resource that is not attached to this session will have no effect.</p>
354+ * <p>Detaching a resource that is not attached to this session will have no effect.
357355 *
358356 * @param resources resources to detach from the session
359357 */
@@ -390,7 +388,8 @@ private synchronized void doClose() {
390388 }
391389 }
392390
393- private static TFE_Context allocate (boolean async , int devicePlacementPolicy , ConfigProto config ) {
391+ private static TFE_Context allocate (
392+ boolean async , int devicePlacementPolicy , ConfigProto config ) {
394393 try (PointerScope scope = new PointerScope ()) {
395394 TFE_ContextOptions opts = TFE_ContextOptions .newContextOptions ();
396395 TF_Status status = TF_Status .newStatus ();
@@ -399,7 +398,7 @@ private static TFE_Context allocate(boolean async, int devicePlacementPolicy, Co
399398 TFE_ContextOptionsSetConfig (opts , configBytes , configBytes .capacity (), status );
400399 status .throwExceptionIfNotOK ();
401400 }
402- TFE_ContextOptionsSetAsync (opts , (byte )(async ? 1 : 0 ));
401+ TFE_ContextOptionsSetAsync (opts , (byte ) (async ? 1 : 0 ));
403402 TFE_ContextOptionsSetDevicePlacementPolicy (opts , devicePlacementPolicy );
404403 TFE_Context context = TFE_NewContext (opts , status );
405404 status .throwExceptionIfNotOK ();
0 commit comments