-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shape.java
45 lines (35 loc) · 939 Bytes
/
Shape.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.tensorflow;
import java.util.Arrays;
public final class Shape {
private long[] shape;
public static Shape unknown() {
return new Shape(null);
}
public static Shape scalar() {
return new Shape(new long[0]);
}
public static Shape make(long j, long... jArr) {
Object obj = new long[(jArr.length + 1)];
obj[0] = j;
System.arraycopy(jArr, 0, obj, 1, jArr.length);
return new Shape(obj);
}
public int numDimensions() {
return this.shape == null ? -1 : this.shape.length;
}
public long size(int i) {
return this.shape[i];
}
public String toString() {
if (this.shape == null) {
return "<unknown>";
}
return Arrays.toString(this.shape).replace("-1", "?");
}
Shape(long[] jArr) {
this.shape = jArr;
}
long[] asArray() {
return this.shape;
}
}