@@ -33,6 +33,7 @@ import org.tensorflow.ndarray.buffer.DoubleDataBuffer
33
33
import org.tensorflow.ndarray.buffer.FloatDataBuffer
34
34
import org.tensorflow.ndarray.buffer.IntDataBuffer
35
35
import org.tensorflow.ndarray.buffer.LongDataBuffer
36
+ import org.tensorflow.ndarray.index.Index
36
37
import org.tensorflow.op.Op
37
38
import org.tensorflow.op.Ops
38
39
import org.tensorflow.op.Scope
@@ -2134,14 +2135,34 @@ public class KotlinOps(
2134
2135
* @throws IllegalArgumentException If the tensor shape is not compatible with the buffer
2135
2136
* @see org.tensorflow.op.Ops.constant
2136
2137
*/
2137
- public fun constant (shape : Shape , `data`: IntDataBuffer ): Constant <TInt32 > = java.constant(
2138
+ public fun constant (shape : Shape , `data`: IntDataBuffer ): Constant <TInt32 > = java.constant(
2138
2139
shape,
2139
2140
data
2141
+ )
2142
+
2143
+ /* *
2144
+ * Creates a scalar of ``` type```, with the value of ``` number```. ``` number``` may be
2145
+ * truncated if it does not
2146
+ * fit in the target type.
2147
+ *
2148
+ * @param type the type of tensor to create. Must be concrete (i.e. not [
2149
+ * org.tensorflow.types.family.TFloating])
2150
+ * @param number the value of the tensor
2151
+ * @return a constant of the passed type
2152
+ * @throws IllegalArgumentException if the type is abstract (i.e. [
2153
+ * org.tensorflow.types.family.TFloating]) or
2154
+ * unknown.
2155
+ * @see org.tensorflow.op.Ops.constant
2156
+ */
2157
+ public fun <T : TNumber > constant (type : Class <T >, number : Number ): Constant <T > =
2158
+ java.constant<T >(
2159
+ type,
2160
+ number
2140
2161
)
2141
2162
2142
2163
/* *
2143
2164
* Create a [ TString] constant with data from the given buffer, using the given encoding.
2144
- *
2165
+ *
2145
2166
* @param scope is a scope used to add the underlying operation.
2146
2167
* @param charset charset used to encode/decode string bytes.
2147
2168
* @param shape the tensor shape.
@@ -2191,24 +2212,42 @@ public class KotlinOps(
2191
2212
* Note: this endpoint cannot be simply called ``` constant} since it will conflict with
2192
2213
* other endpoints accepting an NdArray in parameter {e.g. [ #tensorOf(Scope, FloatNdArray)```
2193
2214
* ].
2194
- *
2215
+ *
2195
2216
* @param scope is a scope used to add the underlying operation.
2196
2217
* @param tensor a Tensor holding the constant value
2197
2218
* @return a constant of the same data type as `tensor`
2198
2219
* @see org.tensorflow.op.Ops.constantOf
2199
2220
*/
2200
- public fun <T : TType > constantOf (tensor : T ): Constant <T > = java.constantOf<T >(
2221
+ public fun <T : TType > constantOf (tensor : T ): Constant <T > = java.constantOf<T >(
2201
2222
tensor
2223
+ )
2224
+
2225
+ /* *
2226
+ * Creates a scalar of the same type as ``` toMatch```, with the value of ``` number```. ```
2227
+ * number``` may be
2228
+ * truncated if it does not fit in the target type.
2229
+ *
2230
+ * @param toMatch the operand providing the target type
2231
+ * @param number the value of the tensor
2232
+ * @return a constant with the same type as ``` toMatch```
2233
+ * @throws IllegalArgumentException if the type is unknown (which should be impossible).
2234
+ * @see Ops#constant(Class, Number)
2235
+ * @see org.tensorflow.op.Ops.constantOfSameType
2236
+ */
2237
+ public fun <T : TNumber > constantOfSameType (toMatch : Operand <T >, number : Number ): Constant <T > =
2238
+ java.constantOfSameType<T >(
2239
+ toMatch,
2240
+ number
2202
2241
)
2203
2242
2204
2243
/* *
2205
2244
* This op consumes a lock created by `MutexLock`.
2206
- *
2245
+ *
2207
2246
* This op exists to consume a tensor created by `MutexLock` (other than
2208
2247
* direct control dependencies). It should be the only that consumes the tensor,
2209
2248
* and will raise an error if it is not. Its only purpose is to keep the
2210
2249
* mutex lock tensor alive until it is consumed by this op.
2211
- *
2250
+ *
2212
2251
* <b>NOTE</b>: This operation must run on the same device as its input. This may
2213
2252
* be enforced via the `colocate_with` mechanism.
2214
2253
*
@@ -4278,7 +4317,7 @@ public class KotlinOps(
4278
4317
4279
4318
/* *
4280
4319
* Creates a one valued tensor given its type and shape.
4281
- *
4320
+ *
4282
4321
* @param scope is a scope used to add the underlying operation
4283
4322
* @param dims a 1-D operand that represents the shape of the output tensor
4284
4323
* @param type the output tensor type class. Can not be TString.
@@ -4287,10 +4326,10 @@ public class KotlinOps(
4287
4326
* ones.
4288
4327
* @see org.tensorflow.op.Ops.ones
4289
4328
*/
4290
- public fun <T : TType , U : TNumber > ones (dims : Operand <U >, type : Class <T >): Ones <T > =
4291
- java.ones<T , U >(
4292
- dims,
4293
- type
4329
+ public fun <T : TType > ones (dims : Operand <out TNumber >, type : Class <T >): Ones <T > =
4330
+ java.ones<T >(
4331
+ dims,
4332
+ type
4294
4333
)
4295
4334
4296
4335
/* *
@@ -7558,22 +7597,97 @@ public class KotlinOps(
7558
7597
* <li>
7559
7598
* Adversarial training, where no backprop should happen through the adversarial
7560
7599
* example generation process.
7561
- *
7600
+ *
7562
7601
* @param T data type for ` output()` output
7563
7602
* @param input
7564
7603
* @return a new instance of StopGradient
7565
7604
* @see org.tensorflow.op.Ops.stopGradient
7566
7605
*/
7567
- public fun <T : TType > stopGradient (input : Operand <T >): StopGradient <T > = java.stopGradient<T >(
7606
+ public fun <T : TType > stopGradient (input : Operand <T >): StopGradient <T > = java.stopGradient<T >(
7568
7607
input
7608
+ )
7609
+
7610
+ /* *
7611
+ * Return a strided slice from `input`.
7612
+ *
7613
+ * The goal of this op is to produce a new tensor with a subset of the elements from the `n`
7614
+ * dimensional `input`
7615
+ * tensor. The subset is chosen using a sequence of `m` sparse range specifications encoded
7616
+ * into the arguments of this
7617
+ * function. Note, in some cases `m` could be equal to `n`, but this need not be the case. Each
7618
+ * range specification
7619
+ * entry can be one of the following:
7620
+ *
7621
+ * - An ellipsis (...) using [ Indices#ellipsis()]. Ellipses are used to imply zero or more
7622
+ * dimensions of
7623
+ * full-dimension selection. For example, ``` stridedSlice(foo, Indices.ellipsis()``` is the
7624
+ * identity slice.
7625
+ *
7626
+ * - A new axis using [ Indices#newAxis()]. This is used to insert a new shape=1 dimension.
7627
+ * For example, ```` stridedSlice(foo, Indices.newAxis())``` where ``` foo``` is shape ``` (3,
7628
+ * 4)```
7629
+ * produces a ``` (1, 3, 4)``` tensor.
7630
+ *
7631
+ * - A range ``` begin:end:stride} using [ Indices#slice(Long, Long, long)``` Index.slice()]
7632
+ * or [ Indices#all()]. This is used to specify
7633
+ * how much to choose from a given dimension. ``` stride``` can be any integer but 0. ```
7634
+ * begin``` is an integer which
7635
+ * represents the index of the first value to select while ``` end``` represents the index of
7636
+ * the last value to select
7637
+ * (exclusive). Begin and end can be null, in which case the index begins or ends at the
7638
+ * beginning or end of the dimension,
7639
+ * respectively (reversed if stride is negative). When both are null, ``` slice()``` is the
7640
+ * same as ``` all()```.
7641
+ * The number of values selected in each dimension is ``` end - begin``` if ``` stride > 0```
7642
+ * and ``` begin - end```
7643
+ * if ``` stride < 0```. ``` begin``` and ``` end``` can be negative where ``` -1``` is the
7644
+ * last element, ``` -2```
7645
+ * is the second to last. For example, given a shape ``` (3,)``` tensor ``` stridedSlice(foo,
7646
+ * Indices.all())```, the
7647
+ * effective ``` begin``` and ``` end``` are ``` 0``` and ``` 3```. Do not assume this is
7648
+ * equivalent to
7649
+ * ``` stridedSlice(foo, Indices.slice(0, -1))``` which has an effective ``` begin``` and ```
7650
+ * end``` of ``` 0``` and
7651
+ * ``` 2```. Another example is ``` stridedSlice(foo, Indices.slice(-2, null, -1))``` which
7652
+ * reverses the first dimension
7653
+ * of a tensor while dropping the last two (in the original order elements). For example ```
7654
+ * foo = [1,2,3,4];
7655
+ * stridedSlice(foo, Indices.slice(-2, null, -1)```
7656
+ * is ``` [4,3]```.
7657
+ *
7658
+ * - A single index using [ Indices#at(long)]. This is used to keep only elements that have a
7659
+ * given index. For
7660
+ * example (``` stridedSlice(foo, Indices.at(2))``` on a shape ``` (5,6)``` tensor produces a
7661
+ * shape ``` (6,)``` tensor.
7662
+ * The dimension can be kept with size one using [ Indices#at(long, boolean)].
7663
+ *
7664
+ * These semantics generally follow NumPy's indexing semantics, which can be found here:
7665
+ * <a
7666
+ * href="https://numpy.org/doc/stable/reference/arrays.indexing.html">https://numpy.org/doc/stable/reference/arrays.indexing.html</a>
7667
+ *
7668
+ *
7669
+ * <i>Requirements</i>:
7670
+ * `0 != strides[i] for i in [0, m)` Only one ellipsis.
7671
+ *
7672
+ * @param scope current scope
7673
+ * @param T data type for ` output()` output
7674
+ * @param indices The indices to slice. See [ Indices].
7675
+ * @return a new instance of StridedSlice
7676
+ * @see Indices
7677
+ * @see org.tensorflow.op.Ops.stridedSlice
7678
+ */
7679
+ public fun <T : TType > stridedSlice (input : Operand <T >, vararg indices : Index ): StridedSlice <T > =
7680
+ java.stridedSlice<T >(
7681
+ input,
7682
+ * indices
7569
7683
)
7570
7684
7571
7685
/* *
7572
7686
* Return a strided slice from `input`.
7573
- *
7687
+ *
7574
7688
* Note, most python users will want to use the Python `Tensor.__getitem__`
7575
7689
* or `Variable.__getitem__` rather than this op directly.
7576
- *
7690
+ *
7577
7691
* The goal of this op is to produce a new tensor with a subset of
7578
7692
* the elements from the `n` dimensional `input` tensor. The subset is chosen using
7579
7693
* a sequence of `m` sparse range specifications encoded into the arguments
@@ -7714,21 +7828,52 @@ public class KotlinOps(
7714
7828
end,
7715
7829
strides,
7716
7830
* listOfNotNull(
7717
- beginMask?.let { org.tensorflow.op.core.StridedSlice .beginMask(it) },
7718
- endMask?.let { org.tensorflow.op.core.StridedSlice .endMask(it) },
7719
- ellipsisMask?.let { org.tensorflow.op.core.StridedSlice .ellipsisMask(it) },
7720
- newAxisMask?.let { org.tensorflow.op.core.StridedSlice .newAxisMask(it) },
7721
- shrinkAxisMask?.let { org.tensorflow.op.core.StridedSlice .shrinkAxisMask(it) }
7831
+ beginMask?.let { org.tensorflow.op.core.StridedSlice .beginMask(it) },
7832
+ endMask?.let { org.tensorflow.op.core.StridedSlice .endMask(it) },
7833
+ ellipsisMask?.let { org.tensorflow.op.core.StridedSlice .ellipsisMask(it) },
7834
+ newAxisMask?.let { org.tensorflow.op.core.StridedSlice .newAxisMask(it) },
7835
+ shrinkAxisMask?.let { org.tensorflow.op.core.StridedSlice .shrinkAxisMask(it) }
7722
7836
).toTypedArray()
7723
- )
7837
+ )
7724
7838
7725
7839
/* *
7726
7840
* Assign `value` to the sliced l-value reference of `ref`.
7727
- *
7841
+ *
7842
+ * The values of `value` are assigned to the positions in the variable `ref` that are selected
7843
+ * by the slice
7844
+ * parameters. The slice parameters `begin`, `end`, `strides`, etc. work exactly as in
7845
+ * `StridedSlice`.
7846
+ *
7847
+ * NOTE this op currently does not support broadcasting and so `value`'s shape must be exactly
7848
+ * the shape produced by
7849
+ * the slice of `ref`.
7850
+ *
7851
+ * @param T data type for ` outputRef()` output
7852
+ * @param scope current scope
7853
+ * @param ref the tensor to assign to.
7854
+ * @param value the value to assign.
7855
+ * @param indices The indices to slice. See [ Indices].
7856
+ * @return a new instance of StridedSliceAssign
7857
+ * @see org.tensorflow.op.Ops#stridedSlice(Operand, Index...)
7858
+ * @see org.tensorflow.op.Ops.stridedSliceAssign
7859
+ */
7860
+ public fun <T : TType > stridedSliceAssign (
7861
+ ref : Operand <T >,
7862
+ value : Operand <T >,
7863
+ vararg indices : Index ,
7864
+ ): StridedSliceAssign <T > = java.stridedSliceAssign<T >(
7865
+ ref,
7866
+ value,
7867
+ * indices
7868
+ )
7869
+
7870
+ /* *
7871
+ * Assign `value` to the sliced l-value reference of `ref`.
7872
+ *
7728
7873
* The values of `value` are assigned to the positions in the variable
7729
7874
* `ref` that are selected by the slice parameters. The slice parameters
7730
7875
* `begin`, `end`, `strides`, etc. work exactly as in `StridedSlice`.
7731
- *
7876
+ *
7732
7877
* NOTE this op currently does not support broadcasting and so `value`'s
7733
7878
* shape must be exactly the shape produced by the slice of `ref`.
7734
7879
*
@@ -9927,7 +10072,7 @@ public class KotlinOps(
9927
10072
9928
10073
/* *
9929
10074
* Creates a zeroed tensor given its type and shape.
9930
- *
10075
+ *
9931
10076
* @param scope is a scope used to add the underlying operation
9932
10077
* @param dims a 1-D operand that represents the shape of the output tensor
9933
10078
* @param type the output tensor datatype
@@ -9936,10 +10081,10 @@ public class KotlinOps(
9936
10081
* zeros.
9937
10082
* @see org.tensorflow.op.Ops.zeros
9938
10083
*/
9939
- public fun <T : TType , U : TNumber > zeros (dims : Operand <U >, type : Class <T >): Zeros <T > =
9940
- java.zeros<T , U >(
9941
- dims,
9942
- type
10084
+ public fun <T : TType > zeros (dims : Operand <out TNumber >, type : Class <T >): Zeros <T > =
10085
+ java.zeros<T >(
10086
+ dims,
10087
+ type
9943
10088
)
9944
10089
9945
10090
/* *
@@ -10007,7 +10152,7 @@ public class KotlinOps(
10007
10152
*
10008
10153
* <i>NOTE</i>: Bitcast is implemented as a low-level cast, so machines with different
10009
10154
* endian orderings will give different results.
10010
- *
10155
+ *
10011
10156
* @param U data type for ` output()` output
10012
10157
* @param input
10013
10158
* @param type
@@ -10016,11 +10161,29 @@ public class KotlinOps(
10016
10161
*/
10017
10162
@JvmName(" bitcastReified" )
10018
10163
public inline fun <reified U : TType > bitcast (input : Operand <out TType >): Bitcast <U > =
10019
- bitcast<U >(input, U ::class .java)
10164
+ bitcast<U >(input, U ::class .java)
10165
+
10166
+ /* *
10167
+ * Creates a scalar of ``` type```, with the value of ``` number```. ``` number``` may be
10168
+ * truncated if it does not
10169
+ * fit in the target type.
10170
+ *
10171
+ * @param type the type of tensor to create. Must be concrete (i.e. not [
10172
+ * org.tensorflow.types.family.TFloating])
10173
+ * @param number the value of the tensor
10174
+ * @return a constant of the passed type
10175
+ * @throws IllegalArgumentException if the type is abstract (i.e. [
10176
+ * org.tensorflow.types.family.TFloating]) or
10177
+ * unknown.
10178
+ * @see org.tensorflow.op.Ops.constant
10179
+ */
10180
+ @JvmName(" constantReified" )
10181
+ public inline fun <reified T : TNumber > constant (number : Number ): Constant <T > =
10182
+ constant<T >(T ::class .java, number)
10020
10183
10021
10184
/* *
10022
10185
* Create a constant with data from the given buffer.
10023
- *
10186
+ *
10024
10187
* @param T the tensor type
10025
10188
* @param scope is a scope used to add the underlying operation.
10026
10189
* @param type the tensor type class
@@ -10284,7 +10447,7 @@ public class KotlinOps(
10284
10447
10285
10448
/* *
10286
10449
* Creates a one valued tensor given its type and shape.
10287
- *
10450
+ *
10288
10451
* @param scope is a scope used to add the underlying operation
10289
10452
* @param dims a 1-D operand that represents the shape of the output tensor
10290
10453
* @param type the output tensor type class. Can not be TString.
@@ -10294,8 +10457,8 @@ public class KotlinOps(
10294
10457
* @see org.tensorflow.op.Ops.ones
10295
10458
*/
10296
10459
@JvmName(" onesReified" )
10297
- public inline fun <reified T : TType , U : TNumber > ones (dims : Operand <U >): Ones <T > = ones<T ,
10298
- U >(dims, T ::class .java)
10460
+ public inline fun <reified T : TType > ones (dims : Operand <out TNumber >): Ones <T > = ones<T >(dims ,
10461
+ T ::class .java)
10299
10462
10300
10463
/* *
10301
10464
* A placeholder op for a value that will be fed into the computation.
@@ -11030,7 +11193,7 @@ public class KotlinOps(
11030
11193
11031
11194
/* *
11032
11195
* Creates a zeroed tensor given its type and shape.
11033
- *
11196
+ *
11034
11197
* @param scope is a scope used to add the underlying operation
11035
11198
* @param dims a 1-D operand that represents the shape of the output tensor
11036
11199
* @param type the output tensor datatype
@@ -11040,6 +11203,6 @@ public class KotlinOps(
11040
11203
* @see org.tensorflow.op.Ops.zeros
11041
11204
*/
11042
11205
@JvmName(" zerosReified" )
11043
- public inline fun <reified T : TType , U : TNumber > zeros (dims : Operand <U >): Zeros <T > = zeros< T ,
11044
- U >(dims, T ::class .java)
11206
+ public inline fun <reified T : TType > zeros (dims : Operand <out TNumber >): Zeros <T > =
11207
+ zeros< T >(dims, T ::class .java)
11045
11208
}
0 commit comments