Skip to content

Commit 04f419a

Browse files
authored
Merge pull request #7 from tensorflow/master
pull type def
2 parents ba294ea + f85623e commit 04f419a

File tree

1,373 files changed

+6846
-7219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,373 files changed

+6846
-7219
lines changed

ndarray/src/main/java/org/tensorflow/ndarray/NdArray.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,7 @@
5555
*
5656
* @param <T> the type of values to be mapped
5757
*/
58-
public interface NdArray<T> {
59-
60-
/**
61-
* @return the shape of this N-dimensional array
62-
*/
63-
Shape shape();
64-
65-
/**
66-
* @return the rank of this N-dimensional array
67-
*/
68-
default int rank() {
69-
return shape().numDimensions();
70-
}
71-
72-
/**
73-
* Computes and returns the total size of this N-dimensional array, in number of values.
74-
*
75-
* <p>For example, given a 3x3x2 matrix, the return value will be 18.
76-
* @return total size of this nd array
77-
*/
78-
default long size() {
79-
return shape().size();
80-
}
58+
public interface NdArray<T> extends Shaped {
8159

8260
/**
8361
* Returns a sequence of all elements at a given dimension.

ndarray/src/main/java/org/tensorflow/ndarray/NdArrays.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static ByteNdArray vectorOf(byte... values) {
6565
if (values == null) {
6666
throw new IllegalArgumentException("Values cannot be null");
6767
}
68-
return wrap(DataBuffers.of(values, false, false), Shape.of(values.length));
68+
return wrap(Shape.of(values.length), DataBuffers.of(values, false, false));
6969
}
7070

7171
/**
@@ -81,19 +81,19 @@ public static ByteNdArray ofBytes(Shape shape) {
8181
if (shape == null) {
8282
throw new IllegalArgumentException("Shape cannot be null");
8383
}
84-
return wrap(DataBuffers.ofBytes(shape.size()), shape);
84+
return wrap(shape, DataBuffers.ofBytes(shape.size()));
8585
}
8686

8787
/**
8888
* Wraps a buffer in a byte N-dimensional array of a given shape.
8989
*
90-
* @param buffer buffer to wrap
9190
* @param shape shape of the array
91+
* @param buffer buffer to wrap
9292
* @return new byte N-dimensional array
9393
* @throws IllegalArgumentException if shape is null, has unknown dimensions or has size bigger
9494
* in the buffer size
9595
*/
96-
public static ByteNdArray wrap(ByteDataBuffer buffer, Shape shape) {
96+
public static ByteNdArray wrap(Shape shape, ByteDataBuffer buffer) {
9797
return ByteDenseNdArray.create(buffer, shape);
9898
}
9999

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright 2020 The TensorFlow Authors. All Rights Reserved.
3+
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
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
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+
=======================================================================
16+
*/
17+
package org.tensorflow.ndarray;
18+
19+
import java.util.function.BiConsumer;
20+
import java.util.function.Consumer;
21+
import org.tensorflow.ndarray.buffer.DataBuffer;
22+
import org.tensorflow.ndarray.index.Index;
23+
24+
/**
25+
* Any data container with a given {@link Shape}.
26+
*/
27+
public interface Shaped {
28+
29+
/**
30+
* @return the shape of this container
31+
*/
32+
Shape shape();
33+
34+
/**
35+
* @return the rank of this container
36+
*/
37+
default int rank() {
38+
return shape().numDimensions();
39+
}
40+
41+
/**
42+
* Computes and returns the total size of this container, in number of values.
43+
*
44+
* <p>For example, given a 3x3x2 matrix, the return value will be 18.
45+
*
46+
* @return number of values in this element
47+
*/
48+
default long size() {
49+
return shape().size();
50+
}
51+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
op {
22
graph_op_name: "BarrierIncompleteSize"
3+
out_arg {
4+
name: "size"
5+
rename_to: "output"
6+
}
37
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
op {
22
graph_op_name: "BarrierReadySize"
3+
out_arg {
4+
name: "size"
5+
rename_to: "output"
6+
}
37
}

tensorflow-core/tensorflow-core-api/src/bazel/api_def/api_def_LookupTableSizeV2.pbtxt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ op {
33
endpoint {
44
name: "LookupTableSize"
55
}
6+
out_arg {
7+
name: "size"
8+
rename_to: "output"
9+
}
610
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
op {
22
graph_op_name: "MapIncompleteSize"
3+
out_arg {
4+
name: "size"
5+
rename_to: "output"
6+
}
37
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
op {
22
graph_op_name: "MapSize"
3+
out_arg {
4+
name: "size"
5+
rename_to: "output"
6+
}
37
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
op {
22
graph_op_name: "OrderedMapIncompleteSize"
3+
out_arg {
4+
name: "size"
5+
rename_to: "output"
6+
}
37
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
op {
22
graph_op_name: "OrderedMapSize"
3+
out_arg {
4+
name: "size"
5+
rename_to: "output"
6+
}
37
}

0 commit comments

Comments
 (0)