5959import org .tensorflow .op .core .BatchToSpace ;
6060import org .tensorflow .op .core .BatchToSpaceNd ;
6161import org .tensorflow .op .core .Bitcast ;
62+ import org .tensorflow .op .core .BooleanMask ;
63+ import org .tensorflow .op .core .BooleanMaskUpdate ;
6264import org .tensorflow .op .core .BroadcastDynamicShape ;
6365import org .tensorflow .op .core .BroadcastTo ;
6466import org .tensorflow .op .core .Bucketize ;
@@ -362,10 +364,10 @@ public final class Ops {
362364
363365 public final SignalOps signal ;
364366
365- public final QuantizationOps quantization ;
366-
367367 public final TrainOps train ;
368368
369+ public final QuantizationOps quantization ;
370+
369371 private final Scope scope ;
370372
371373 private Ops (Scope scope ) {
@@ -388,8 +390,8 @@ private Ops(Scope scope) {
388390 math = new MathOps (this );
389391 audio = new AudioOps (this );
390392 signal = new SignalOps (this );
391- quantization = new QuantizationOps (this );
392393 train = new TrainOps (this );
394+ quantization = new QuantizationOps (this );
393395 }
394396
395397 /**
@@ -1005,6 +1007,61 @@ public <U extends TType> Bitcast<U> bitcast(Operand<? extends TType> input, Clas
10051007 return Bitcast .create (scope , input , type );
10061008 }
10071009
1010+ /**
1011+ * Apply boolean mask to tensor. Returns the flat array of each element corresponding to a {@code true} in the mask.
1012+ * <p>
1013+ * Numpy equivalent is {@code tensor[mask]}.
1014+ * <p>
1015+ * In general, {@code 0 < dim(mask) = K <= dim(tensor)}, and {@code mask}'s shape must match
1016+ * the first K dimensions of {@code tensor}'s shape. We then have:
1017+ * {@code booleanMask(tensor, mask)[i, j1,...,jd] = tensor[i1,...,iK,j1,...,jd]}
1018+ * where {@code (i1,...,iK)} is the ith {@code true} entry of {@code mask} (row-major order).
1019+ * <p>
1020+ * The {@code axis} could be used with {@code mask} to indicate the axis to mask from (it's 0 by default).
1021+ * In that case, {@code axis + dim(mask) <= dim(tensor)} and {@code mask}'s shape must match
1022+ * the first {@code axis + dim(mask)} dimensions of {@code tensor}'s shape.
1023+ *
1024+ * @param scope
1025+ * @param tensor The tensor to mask.
1026+ * @param mask The mask to apply.
1027+ * @param options carries optional attributes values
1028+ * @return The masked tensor.
1029+ */
1030+ public <T extends TType > Operand <T > booleanMask (Operand <T > tensor , Operand <TBool > mask ,
1031+ BooleanMask .Options ... options ) {
1032+ return BooleanMask .create (scope , tensor , mask , options );
1033+ }
1034+
1035+ /**
1036+ * Updates a tensor at the masked values, and returns the updated tensor. Does not mutate the input tensors. {@code
1037+ * updates} will be broadcasted by default
1038+ * <p>
1039+ * Numpy equivalent is `tensor[mask] = updates`.
1040+ * <p>
1041+ * In general, {@code 0 < dim(mask) = K <= dim(tensor)}, and {@code mask}'s shape must match the first K dimensions of
1042+ * {@code tensor}'s shape. We then have: {@code booleanMask(tensor, mask)[i, j1,...,jd] =
1043+ * tensor[i1,...,iK,j1,...,jd]} where {@code (i1,...,iK)} is the ith {@code true} entry of {@code mask} (row-major
1044+ * order).
1045+ * <p>
1046+ * The {@code axis} could be used with {@code mask} to indicate the axis to mask from (it's 0 by default). In that
1047+ * case, {@code axis + dim(mask) <= dim(tensor)} and {@code mask}'s shape must match the first {@code axis +
1048+ * dim(mask)} dimensions of {@code tensor}'s shape.
1049+ * <p>
1050+ * The shape of {@code updates} should be {@code [n, t_1, t_2, ...]} where {@code n} is the number of true values in
1051+ * {@code mask} and {@code t_i} is the {@code i}th dimension of {@code tensor} after {@code axis} and {@code mask}.
1052+ * {@code updates} will be broadcasted to this shape by default, which can be disabled using {@code options}.
1053+ *
1054+ * @param tensor The tensor to mask.
1055+ * @param mask The mask to apply.
1056+ * @param updates the new values
1057+ * @param options carries optional attributes values
1058+ * @return The masked tensor.
1059+ */
1060+ public <T extends TType > Operand <T > booleanMaskUpdate (Operand <T > tensor , Operand <TBool > mask ,
1061+ Operand <T > updates , BooleanMaskUpdate .Options ... options ) {
1062+ return BooleanMaskUpdate .create (scope , tensor , mask , updates , options );
1063+ }
1064+
10081065 /**
10091066 * Return the shape of s0 op s1 with broadcast.
10101067 * <p>
@@ -1850,13 +1907,14 @@ public Constant<TInt32> constant(Shape shape, IntDataBuffer data) {
18501907 }
18511908
18521909 /**
1853- * Creates a scalar of {@code type}, with the value of {@code number}.
1854- * {@code number} may be truncated if it does not fit in the target type.
1910+ * Creates a scalar of {@code type}, with the value of {@code number}. {@code number} may be truncated if it does not
1911+ * fit in the target type.
18551912 *
18561913 * @param type the type of tensor to create. Must be concrete (i.e. not {@link org.tensorflow.types.family.TFloating})
18571914 * @param number the value of the tensor
18581915 * @return a constant of the passed type
1859- * @throws IllegalArgumentException if the type is abstract (i.e. {@link org.tensorflow.types.family.TFloating}) or unknown.
1916+ * @throws IllegalArgumentException if the type is abstract (i.e. {@link org.tensorflow.types.family.TFloating}) or
1917+ * unknown.
18601918 */
18611919 public <T extends TNumber > Constant <T > constant (Class <T > type , Number number ) {
18621920 return Constant .tensorOf (scope , type , number );
@@ -1908,14 +1966,14 @@ public <T extends TType> Constant<T> constantOf(T tensor) {
19081966 }
19091967
19101968 /**
1911- * Creates a scalar of the same type as {@code toMatch}, with the value of {@code number}.
1912- * {@code number} may be truncated if it does not fit in the target type.
1969+ * Creates a scalar of the same type as {@code toMatch}, with the value of {@code number}. {@code number} may be
1970+ * truncated if it does not fit in the target type.
19131971 *
19141972 * @param toMatch the operand providing the target type
19151973 * @param number the value of the tensor
19161974 * @return a constant with the same type as {@code toMatch}
1917- * @see Ops#constant(Class, Number)
19181975 * @throws IllegalArgumentException if the type is unknown (which should be impossible).
1976+ * @see Ops#constant(Class, Number)
19191977 */
19201978 public <T extends TNumber > Constant <T > constantOfSameType (Operand <T > toMatch , Number number ) {
19211979 return Constant .tensorOfSameType (scope , toMatch , number );
0 commit comments