Skip to content

Commit ac1f418

Browse files
committed
remove old Index class
Signed-off-by: Ryan Nett <[email protected]>
1 parent 7a69f90 commit ac1f418

File tree

6 files changed

+87
-428
lines changed

6 files changed

+87
-428
lines changed

ndarray/src/main/java/org/tensorflow/ndarray/index/Indices.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ public static Index hyperslab(long start, long stride, long count, long block) {
258258

259259
//TODO comments, tests, remove extra classes in favor of helper methods
260260

261+
/**
262+
*
263+
* @return
264+
*/
261265
public static TensorIndex newAxis(){
262266
return NewAxis.INSTANCE;
263267
}
@@ -270,7 +274,31 @@ public static TensorIndex expand(){
270274
return ellipsis();
271275
}
272276

277+
public static TensorIndex slice(Long start, Long end){
278+
return slice(start, end, 1);
279+
}
280+
273281
public static TensorIndex slice(Long start, Long end, long stride){
274282
return new Slice(start, end, stride);
275283
}
284+
285+
public static TensorIndex slice(Integer start, int end){
286+
return intSlice(start, end, 1);
287+
}
288+
289+
public static TensorIndex slice(int start, Integer end){
290+
return intSlice(start, end, 1);
291+
}
292+
293+
public static TensorIndex slice(Integer start, int end, long stride){
294+
return intSlice(start, end, stride);
295+
}
296+
297+
public static TensorIndex slice(int start, Integer end, long stride){
298+
return intSlice(start, end, stride);
299+
}
300+
301+
private static TensorIndex intSlice(Integer start, Integer end, long stride){
302+
return new Slice(start == null ? null : start.longValue(), end == null ? null : end.longValue(), stride);
303+
}
276304
}

tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.tensorflow.ndarray.buffer.FloatDataBuffer;
4141
import org.tensorflow.ndarray.buffer.IntDataBuffer;
4242
import org.tensorflow.ndarray.buffer.LongDataBuffer;
43+
import org.tensorflow.ndarray.index.TensorIndex;
4344
import org.tensorflow.op.core.Abort;
4445
import org.tensorflow.op.core.All;
4546
import org.tensorflow.op.core.Any;
@@ -95,7 +96,6 @@
9596
import org.tensorflow.op.core.Identity;
9697
import org.tensorflow.op.core.IdentityN;
9798
import org.tensorflow.op.core.ImmutableConst;
98-
import org.tensorflow.op.core.Indexing;
9999
import org.tensorflow.op.core.Init;
100100
import org.tensorflow.op.core.InitializeTable;
101101
import org.tensorflow.op.core.InitializeTableFromTextFile;
@@ -213,6 +213,7 @@
213213
import org.tensorflow.op.core.StridedSlice;
214214
import org.tensorflow.op.core.StridedSliceAssign;
215215
import org.tensorflow.op.core.StridedSliceGrad;
216+
import org.tensorflow.op.core.StridedSliceHelper;
216217
import org.tensorflow.op.core.Sum;
217218
import org.tensorflow.op.core.SwitchCond;
218219
import org.tensorflow.op.core.TemporaryVariable;
@@ -5910,15 +5911,15 @@ public <T extends TType> StopGradient<T> stopGradient(Operand<T> input) {
59105911
* `m` could be equal to `n`, but this need not be the case. Each
59115912
* range specification entry can be one of the following:
59125913
* <p>
5913-
* - An ellipsis (...) using {@link Index#ellipses()}. Ellipses are used to imply zero or more
5914+
* - An ellipsis (...) using {@link Indices#ellipsis()}. Ellipses are used to imply zero or more
59145915
* dimensions of full-dimension selection and are produced using
59155916
* `ellipsis_mask`. For example, `foo[...]` is the identity slice.
59165917
* <p>
5917-
* - A new axis using {@link Index#newAxis()}. This is used to insert a new shape=1 dimension and is
5918+
* - A new axis using {@link Indices#newAxis()}. This is used to insert a new shape=1 dimension and is
59185919
* produced using `new_axis_mask`. For example, `foo[:, ...]` where
59195920
* `foo` is shape `(3, 4)` produces a `(1, 3, 4)` tensor.
59205921
* <p>
5921-
* - A range `begin:end:stride` using {@link Index#slice(Singular, Singular, int) Index.slice()} or {@link Index#all()}. This is used to specify how much to choose from
5922+
* - A range `begin:end:stride` using {@link Indices#slice(Long, Long, long)} Index.slice()}. This is used to specify how much to choose from
59225923
* a given dimension. `stride` can be any integer but 0. `begin` is an integer
59235924
* which represents the index of the first value to select while `end` represents
59245925
* the index of the last value to select. The number of values selected in each
@@ -5934,7 +5935,7 @@ public <T extends TType> StopGradient<T> stopGradient(Operand<T> input) {
59345935
* first dimension of a tensor while dropping the last two (in the original
59355936
* order elements). For example `foo = [1,2,3,4]; foo[-2::-1]` is `[4,3]`.
59365937
* <p>
5937-
* - A single index using {@link Index#point(int)}. This is used to keep only elements that have a given
5938+
* - A single index using {@link Indices#at(long)}. This is used to keep only elements that have a given
59385939
* index. For example (`foo[2, :]` on a shape `(5,6)` tensor produces a
59395940
* shape `(6,)` tensor. This is encoded in `begin` and `end` and
59405941
* `shrink_axis_mask`.
@@ -5947,12 +5948,12 @@ public <T extends TType> StopGradient<T> stopGradient(Operand<T> input) {
59475948
* @param scope current scope
59485949
* @param <T> data type for {@code output()} output
59495950
* @param input
5950-
* @param indices The indices to slice. See {@link Index}.
5951+
* @param indices The indices to slice. See {@link Indices}.
59515952
* @return a new instance of StridedSlice
5952-
* @see Index
5953+
* @see Indices
59535954
*/
5954-
public <T extends TType> StridedSlice<T> stridedSlice(Operand<T> input, Index... indices) {
5955-
return Indexing.stridedSlice(scope, input, indices);
5955+
public <T extends TType> StridedSlice<T> stridedSlice(Operand<T> input, TensorIndex... indices) {
5956+
return StridedSliceHelper.stridedSlice(scope, input, indices);
59565957
}
59575958

59585959
/**
@@ -6081,13 +6082,13 @@ public <T extends TType, U extends TNumber> StridedSlice<T> stridedSlice(Operand
60816082
* @param scope current scope
60826083
* @param ref the tensor to assign to.
60836084
* @param value the value to assign.
6084-
* @param indices The indices to slice. See {@link Index}.
6085+
* @param indices The indices to slice. See {@link Indices}.
60856086
* @return a new instance of StridedSliceAssign
6086-
* @see org.tensorflow.op.Ops#stridedSlice(Operand, Index...)
6087+
* @see org.tensorflow.op.Ops#stridedSlice(Operand, TensorIndex...)
60876088
*/
60886089
public <T extends TType> StridedSliceAssign<T> stridedSliceAssign(Operand<T> ref,
6089-
Operand<T> value, Index... indices) {
6090-
return Indexing.stridedSliceAssign(scope, ref, value, indices);
6090+
Operand<T> value, TensorIndex... indices) {
6091+
return StridedSliceHelper.stridedSliceAssign(scope, ref, value, indices);
60916092
}
60926093

60936094
/**

0 commit comments

Comments
 (0)