Skip to content

Commit ab6cb65

Browse files
committed
remove old Index class
Signed-off-by: Ryan Nett <[email protected]>
1 parent 75a8919 commit ab6cb65

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
@@ -38,6 +38,7 @@
3838
import org.tensorflow.ndarray.buffer.FloatDataBuffer;
3939
import org.tensorflow.ndarray.buffer.IntDataBuffer;
4040
import org.tensorflow.ndarray.buffer.LongDataBuffer;
41+
import org.tensorflow.ndarray.index.TensorIndex;
4142
import org.tensorflow.op.core.Abort;
4243
import org.tensorflow.op.core.All;
4344
import org.tensorflow.op.core.Any;
@@ -93,7 +94,6 @@
9394
import org.tensorflow.op.core.Identity;
9495
import org.tensorflow.op.core.IdentityN;
9596
import org.tensorflow.op.core.ImmutableConst;
96-
import org.tensorflow.op.core.Indexing;
9797
import org.tensorflow.op.core.Init;
9898
import org.tensorflow.op.core.InitializeTable;
9999
import org.tensorflow.op.core.InitializeTableFromTextFile;
@@ -211,6 +211,7 @@
211211
import org.tensorflow.op.core.StridedSlice;
212212
import org.tensorflow.op.core.StridedSliceAssign;
213213
import org.tensorflow.op.core.StridedSliceGrad;
214+
import org.tensorflow.op.core.StridedSliceHelper;
214215
import org.tensorflow.op.core.Sum;
215216
import org.tensorflow.op.core.SwitchCond;
216217
import org.tensorflow.op.core.TemporaryVariable;
@@ -5912,15 +5913,15 @@ public <T extends TType> StopGradient<T> stopGradient(Operand<T> input) {
59125913
* `m` could be equal to `n`, but this need not be the case. Each
59135914
* range specification entry can be one of the following:
59145915
* <p>
5915-
* - An ellipsis (...) using {@link Index#ellipses()}. Ellipses are used to imply zero or more
5916+
* - An ellipsis (...) using {@link Indices#ellipsis()}. Ellipses are used to imply zero or more
59165917
* dimensions of full-dimension selection and are produced using
59175918
* `ellipsis_mask`. For example, `foo[...]` is the identity slice.
59185919
* <p>
5919-
* - A new axis using {@link Index#newAxis()}. This is used to insert a new shape=1 dimension and is
5920+
* - A new axis using {@link Indices#newAxis()}. This is used to insert a new shape=1 dimension and is
59205921
* produced using `new_axis_mask`. For example, `foo[:, ...]` where
59215922
* `foo` is shape `(3, 4)` produces a `(1, 3, 4)` tensor.
59225923
* <p>
5923-
* - 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
5924+
* - A range `begin:end:stride` using {@link Indices#slice(Long, Long, long)} Index.slice()}. This is used to specify how much to choose from
59245925
* a given dimension. `stride` can be any integer but 0. `begin` is an integer
59255926
* which represents the index of the first value to select while `end` represents
59265927
* the index of the last value to select. The number of values selected in each
@@ -5936,7 +5937,7 @@ public <T extends TType> StopGradient<T> stopGradient(Operand<T> input) {
59365937
* first dimension of a tensor while dropping the last two (in the original
59375938
* order elements). For example `foo = [1,2,3,4]; foo[-2::-1]` is `[4,3]`.
59385939
* <p>
5939-
* - A single index using {@link Index#point(int)}. This is used to keep only elements that have a given
5940+
* - A single index using {@link Indices#at(long)}. This is used to keep only elements that have a given
59405941
* index. For example (`foo[2, :]` on a shape `(5,6)` tensor produces a
59415942
* shape `(6,)` tensor. This is encoded in `begin` and `end` and
59425943
* `shrink_axis_mask`.
@@ -5949,12 +5950,12 @@ public <T extends TType> StopGradient<T> stopGradient(Operand<T> input) {
59495950
* @param scope current scope
59505951
* @param <T> data type for {@code output()} output
59515952
* @param input
5952-
* @param indices The indices to slice. See {@link Index}.
5953+
* @param indices The indices to slice. See {@link Indices}.
59535954
* @return a new instance of StridedSlice
5954-
* @see Index
5955+
* @see Indices
59555956
*/
5956-
public <T extends TType> StridedSlice<T> stridedSlice(Operand<T> input, Index... indices) {
5957-
return Indexing.stridedSlice(scope, input, indices);
5957+
public <T extends TType> StridedSlice<T> stridedSlice(Operand<T> input, TensorIndex... indices) {
5958+
return StridedSliceHelper.stridedSlice(scope, input, indices);
59585959
}
59595960

59605961
/**
@@ -6083,13 +6084,13 @@ public <T extends TType, U extends TNumber> StridedSlice<T> stridedSlice(Operand
60836084
* @param scope current scope
60846085
* @param ref the tensor to assign to.
60856086
* @param value the value to assign.
6086-
* @param indices The indices to slice. See {@link Index}.
6087+
* @param indices The indices to slice. See {@link Indices}.
60876088
* @return a new instance of StridedSliceAssign
6088-
* @see org.tensorflow.op.Ops#stridedSlice(Operand, Index...)
6089+
* @see org.tensorflow.op.Ops#stridedSlice(Operand, TensorIndex...)
60896090
*/
60906091
public <T extends TType> StridedSliceAssign<T> stridedSliceAssign(Operand<T> ref,
6091-
Operand<T> value, Index... indices) {
6092-
return Indexing.stridedSliceAssign(scope, ref, value, indices);
6092+
Operand<T> value, TensorIndex... indices) {
6093+
return StridedSliceHelper.stridedSliceAssign(scope, ref, value, indices);
60936094
}
60946095

60956096
/**

0 commit comments

Comments
 (0)