Skip to content

Commit bfa702b

Browse files
committed
Formatting, Jupyter integration
Signed-off-by: Ryan Nett <[email protected]>
1 parent eee0f9f commit bfa702b

File tree

30 files changed

+676
-378
lines changed

30 files changed

+676
-378
lines changed

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/ExecutionEnvironment.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/* Copyright 2019-2021 The TensorFlow Authors. All Rights Reserved.
22
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
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
66
7-
http://www.apache.org/licenses/LICENSE-2.0
7+
http://www.apache.org/licenses/LICENSE-2.0
88
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-
*/
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+
*/
1616
package org.tensorflow;
1717

1818
import org.tensorflow.op.Op;
@@ -90,7 +90,7 @@ default boolean isGraph() {
9090
Scope baseScope();
9191

9292
@Override
93-
default Ops tf(){
93+
default Ops tf() {
9494
return Ops.create(this);
9595
}
9696
}

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/Signature.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/* Copyright 2020-2021 The TensorFlow Authors. All Rights Reserved.
22
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-
*/
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+
*/
1616
package org.tensorflow;
1717

1818
import java.util.Collections;

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/op/WithOps.java

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
11
/*
2-
Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2+
Copyright 2021 The TensorFlow Authors. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
=======================================================================
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
=======================================================================
1616
17-
*/
17+
*/
1818
package org.tensorflow.op;
1919

2020
import java.util.Arrays;
2121
import org.tensorflow.DeviceSpec;
2222

23-
/**
24-
* A context that provides a TensorFlow op builder.
25-
*/
23+
/** A context that provides a TensorFlow op builder. */
2624
public interface WithOps {
2725

28-
/**
29-
* Get the op builder for this context.
30-
*/
26+
/** Get the op builder for this context. */
3127
Ops tf();
3228

3329
/**
@@ -62,7 +58,7 @@ default WithOps withDevice(DeviceSpec deviceSpec) {
6258
*
6359
* @see Scope#withControlDependencies(Iterable)
6460
*/
65-
default WithOps withControlDependencies(Iterable<Op> controls){
61+
default WithOps withControlDependencies(Iterable<Op> controls) {
6662
return tf().withControlDependencies(controls);
6763
}
6864

@@ -71,8 +67,7 @@ default WithOps withControlDependencies(Iterable<Op> controls){
7167
*
7268
* @see Scope#withControlDependencies(Iterable)
7369
*/
74-
default WithOps withControlDependencies(Op... controls){
70+
default WithOps withControlDependencies(Op... controls) {
7571
return withControlDependencies(Arrays.asList(controls));
7672
}
77-
7873
}

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/op/nn/SoftmaxCrossEntropyWithLogits.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.tensorflow.op.nn;
22

3+
import java.util.Arrays;
4+
import java.util.List;
35
import org.tensorflow.Operand;
46
import org.tensorflow.ndarray.Shape;
57
import org.tensorflow.op.Scope;
@@ -15,9 +17,6 @@
1517
import org.tensorflow.types.TInt64;
1618
import org.tensorflow.types.family.TNumber;
1719

18-
import java.util.Arrays;
19-
import java.util.List;
20-
2120
@Operator(group = "nn")
2221
public class SoftmaxCrossEntropyWithLogits {
2322

@@ -77,18 +76,18 @@ public static <T extends TNumber, U extends TNumber> Operand<T> softmaxCrossEntr
7776
}
7877

7978
if (logits.asOutput().type() == TFloat16.class || logits.asOutput().type() == TBfloat16.class) {
80-
Operand<TFloat32> result = softmaxCrossEntropyWithLogits(scope,
79+
Operand<TFloat32> result =
80+
softmaxCrossEntropyWithLogits(
81+
scope,
8182
Cast.create(scope, labels, TFloat32.class),
8283
Cast.create(scope, logits, TFloat32.class),
8384
axis);
8485
return Cast.create(scope, result, logits.asOutput().type());
8586
}
8687

8788
if (logits.asOutput().type() != labels.asOutput().type()) {
88-
return softmaxCrossEntropyWithLogits(scope,
89-
Cast.create(scope, labels, logits.asOutput().type()),
90-
logits,
91-
axis);
89+
return softmaxCrossEntropyWithLogits(
90+
scope, Cast.create(scope, labels, logits.asOutput().type()), logits, axis);
9291
}
9392

9493
Operand<TInt64> inputRank = Cast.create(scope, Rank.create(scope, logits), TInt64.class);
@@ -106,7 +105,7 @@ public static <T extends TNumber, U extends TNumber> Operand<T> softmaxCrossEntr
106105

107106
org.tensorflow.op.nn.raw.SoftmaxCrossEntropyWithLogits<T> smax =
108107
org.tensorflow.op.nn.raw.SoftmaxCrossEntropyWithLogits.create(
109-
scope, logits, (Operand<T>)labels);
108+
scope, logits, (Operand<T>) labels);
110109
/* cannot use generic on cost, because cost may be recast later. */
111110
Operand<T> cost = smax.loss();
112111
Operand<TInt64> outputShape =

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/op/nn/SparseSoftmaxCrossEntropyWithLogits.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.tensorflow.op.nn;
22

3+
import java.util.ArrayList;
4+
import java.util.Collections;
5+
import java.util.List;
36
import org.tensorflow.Operand;
47
import org.tensorflow.ndarray.Shape;
58
import org.tensorflow.op.Op;
@@ -18,10 +21,6 @@
1821
import org.tensorflow.types.TInt32;
1922
import org.tensorflow.types.family.TNumber;
2023

21-
import java.util.ArrayList;
22-
import java.util.Collections;
23-
import java.util.List;
24-
2524
@Operator(group = "nn")
2625
public class SparseSoftmaxCrossEntropyWithLogits {
2726

tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/EagerOperationTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
import org.tensorflow.types.TFloat32;
2727
import org.tensorflow.types.TInt32;
2828

29-
/**
30-
* Unit tests for {@link EagerOperation} class.
31-
*/
29+
/** Unit tests for {@link EagerOperation} class. */
3230
public class EagerOperationTest {
3331

3432
@Test
@@ -50,7 +48,7 @@ public void failToCreateIfSessionIsClosed() {
5048
@Test
5149
public void outputDataTypeAndShape() {
5250
try (EagerSession session = EagerSession.create();
53-
TInt32 t = TInt32.tensorOf(Shape.of(2, 3))) {
51+
TInt32 t = TInt32.tensorOf(Shape.of(2, 3))) {
5452
EagerOperation op =
5553
opBuilder(session, "Const", "OutputAttrs")
5654
.setAttr("dtype", t.dataType())
@@ -71,7 +69,7 @@ public void outputTensor() {
7169
.addInput(tf.constant(2).asOutput())
7270
.addInput(tf.constant(4).asOutput())
7371
.build();
74-
assertEquals(6, ((TInt32)add.tensor(0)).getInt());
72+
assertEquals(6, ((TInt32) add.tensor(0)).getInt());
7573

7674
// Validate that we retrieve the right shape and datatype from the tensor
7775
// that has been resolved
@@ -84,12 +82,12 @@ public void outputTensor() {
8482
public void inputAndOutputListLengths() {
8583
try (EagerSession session = EagerSession.create()) {
8684
Ops tf = Ops.create(session);
87-
Output<TFloat32> c1 = tf.constant(new float[]{1f, 2f}).asOutput();
88-
Output<TFloat32> c2 = tf.constant(new float[]{3f, 4f}).asOutput();
85+
Output<TFloat32> c1 = tf.constant(new float[] {1f, 2f}).asOutput();
86+
Output<TFloat32> c2 = tf.constant(new float[] {3f, 4f}).asOutput();
8987

9088
EagerOperation acc =
9189
opBuilder(session, "AddN", "InputListLength")
92-
.addInputList(new Output<?>[]{c1, c2})
90+
.addInputList(new Output<?>[] {c1, c2})
9391
.build();
9492
assertEquals(2, acc.inputListLength("inputs"));
9593
assertEquals(1, acc.outputListLength("sum"));
@@ -125,8 +123,8 @@ public void numOutputs() {
125123
Ops tf = Ops.create(session);
126124
EagerOperation op =
127125
opBuilder(session, "UniqueWithCountsV2", "unq")
128-
.addInput(tf.constant(new int[]{1, 2, 1}).asOutput())
129-
.addInput(tf.constant(new int[]{0}).asOutput())
126+
.addInput(tf.constant(new int[] {1, 2, 1}).asOutput())
127+
.addInput(tf.constant(new int[] {0}).asOutput())
130128
.setAttr("out_idx", DataType.DT_INT32)
131129
.build();
132130
assertEquals(3, op.numOutputs());

tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/GraphOperationBuilderTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/* Copyright 2019-2021 The TensorFlow Authors. All Rights Reserved.
22
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-
*/
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+
*/
1616
package org.tensorflow;
1717

1818
import static org.junit.jupiter.api.Assertions.assertEquals;

tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/SavedModelBundleTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/* Copyright 2019-2021 The TensorFlow Authors. All Rights Reserved.
22
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
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
66
7-
http://www.apache.org/licenses/LICENSE-2.0
7+
http://www.apache.org/licenses/LICENSE-2.0
88
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-
*/
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+
*/
1616
package org.tensorflow;
1717

1818
import static org.junit.jupiter.api.Assertions.assertEquals;

0 commit comments

Comments
 (0)