Skip to content

Commit ebf193e

Browse files
committed
remove old Index class
Signed-off-by: Ryan Nett <[email protected]>
1 parent 02f7886 commit ebf193e

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
@@ -39,6 +39,7 @@
3939
import org.tensorflow.ndarray.buffer.FloatDataBuffer;
4040
import org.tensorflow.ndarray.buffer.IntDataBuffer;
4141
import org.tensorflow.ndarray.buffer.LongDataBuffer;
42+
import org.tensorflow.ndarray.index.TensorIndex;
4243
import org.tensorflow.op.core.Abort;
4344
import org.tensorflow.op.core.All;
4445
import org.tensorflow.op.core.Any;
@@ -94,7 +95,6 @@
9495
import org.tensorflow.op.core.Identity;
9596
import org.tensorflow.op.core.IdentityN;
9697
import org.tensorflow.op.core.ImmutableConst;
97-
import org.tensorflow.op.core.Indexing;
9898
import org.tensorflow.op.core.Init;
9999
import org.tensorflow.op.core.InitializeTable;
100100
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;
@@ -5895,15 +5896,15 @@ public <T extends TType> StopGradient<T> stopGradient(Operand<T> input) {
58955896
* `m` could be equal to `n`, but this need not be the case. Each
58965897
* range specification entry can be one of the following:
58975898
* <p>
5898-
* - An ellipsis (...) using {@link Index#ellipses()}. Ellipses are used to imply zero or more
5899+
* - An ellipsis (...) using {@link Indices#ellipsis()}. Ellipses are used to imply zero or more
58995900
* dimensions of full-dimension selection and are produced using
59005901
* `ellipsis_mask`. For example, `foo[...]` is the identity slice.
59015902
* <p>
5902-
* - A new axis using {@link Index#newAxis()}. This is used to insert a new shape=1 dimension and is
5903+
* - A new axis using {@link Indices#newAxis()}. This is used to insert a new shape=1 dimension and is
59035904
* produced using `new_axis_mask`. For example, `foo[:, ...]` where
59045905
* `foo` is shape `(3, 4)` produces a `(1, 3, 4)` tensor.
59055906
* <p>
5906-
* - 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
5907+
* - A range `begin:end:stride` using {@link Indices#slice(Long, Long, long)} Index.slice()}. This is used to specify how much to choose from
59075908
* a given dimension. `stride` can be any integer but 0. `begin` is an integer
59085909
* which represents the index of the first value to select while `end` represents
59095910
* the index of the last value to select. The number of values selected in each
@@ -5919,7 +5920,7 @@ public <T extends TType> StopGradient<T> stopGradient(Operand<T> input) {
59195920
* first dimension of a tensor while dropping the last two (in the original
59205921
* order elements). For example `foo = [1,2,3,4]; foo[-2::-1]` is `[4,3]`.
59215922
* <p>
5922-
* - A single index using {@link Index#point(int)}. This is used to keep only elements that have a given
5923+
* - A single index using {@link Indices#at(long)}. This is used to keep only elements that have a given
59235924
* index. For example (`foo[2, :]` on a shape `(5,6)` tensor produces a
59245925
* shape `(6,)` tensor. This is encoded in `begin` and `end` and
59255926
* `shrink_axis_mask`.
@@ -5932,12 +5933,12 @@ public <T extends TType> StopGradient<T> stopGradient(Operand<T> input) {
59325933
* @param scope current scope
59335934
* @param <T> data type for {@code output()} output
59345935
* @param input
5935-
* @param indices The indices to slice. See {@link Index}.
5936+
* @param indices The indices to slice. See {@link Indices}.
59365937
* @return a new instance of StridedSlice
5937-
* @see Index
5938+
* @see Indices
59385939
*/
5939-
public <T extends TType> StridedSlice<T> stridedSlice(Operand<T> input, Index... indices) {
5940-
return Indexing.stridedSlice(scope, input, indices);
5940+
public <T extends TType> StridedSlice<T> stridedSlice(Operand<T> input, TensorIndex... indices) {
5941+
return StridedSliceHelper.stridedSlice(scope, input, indices);
59415942
}
59425943

59435944
/**
@@ -6066,13 +6067,13 @@ public <T extends TType, U extends TNumber> StridedSlice<T> stridedSlice(Operand
60666067
* @param scope current scope
60676068
* @param ref the tensor to assign to.
60686069
* @param value the value to assign.
6069-
* @param indices The indices to slice. See {@link Index}.
6070+
* @param indices The indices to slice. See {@link Indices}.
60706071
* @return a new instance of StridedSliceAssign
6071-
* @see org.tensorflow.op.Ops#stridedSlice(Operand, Index...)
6072+
* @see org.tensorflow.op.Ops#stridedSlice(Operand, TensorIndex...)
60726073
*/
60736074
public <T extends TType> StridedSliceAssign<T> stridedSliceAssign(Operand<T> ref,
6074-
Operand<T> value, Index... indices) {
6075-
return Indexing.stridedSliceAssign(scope, ref, value, indices);
6075+
Operand<T> value, TensorIndex... indices) {
6076+
return StridedSliceHelper.stridedSliceAssign(scope, ref, value, indices);
60766077
}
60776078

60786079
/**

0 commit comments

Comments
 (0)