Skip to content

Commit 50974f8

Browse files
committed
Update to new master
Signed-off-by: Ryan Nett <[email protected]>
1 parent 75b53f3 commit 50974f8

File tree

4 files changed

+254
-69
lines changed
  • tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op
  • tensorflow-core-kotlin/tensorflow-core-kotlin-api/src

4 files changed

+254
-69
lines changed

tensorflow-core-kotlin/tensorflow-core-kotlin-api/src/gen/annotations/org/tensorflow/op/kotlin/KotlinOps.kt

Lines changed: 200 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import org.tensorflow.ndarray.buffer.DoubleDataBuffer
3333
import org.tensorflow.ndarray.buffer.FloatDataBuffer
3434
import org.tensorflow.ndarray.buffer.IntDataBuffer
3535
import org.tensorflow.ndarray.buffer.LongDataBuffer
36+
import org.tensorflow.ndarray.index.Index
3637
import org.tensorflow.op.Op
3738
import org.tensorflow.op.Ops
3839
import org.tensorflow.op.Scope
@@ -2134,14 +2135,34 @@ public class KotlinOps(
21342135
* @throws IllegalArgumentException If the tensor shape is not compatible with the buffer
21352136
* @see org.tensorflow.op.Ops.constant
21362137
*/
2137-
public fun constant(shape: Shape, `data`: IntDataBuffer): Constant<TInt32> = java.constant(
2138+
public fun constant(shape: Shape, `data`: IntDataBuffer): Constant<TInt32> = java.constant(
21382139
shape,
21392140
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
21402161
)
21412162

21422163
/**
21432164
* Create a [ TString] constant with data from the given buffer, using the given encoding.
2144-
*
2165+
*
21452166
* @param scope is a scope used to add the underlying operation.
21462167
* @param charset charset used to encode/decode string bytes.
21472168
* @param shape the tensor shape.
@@ -2191,24 +2212,42 @@ public class KotlinOps(
21912212
* Note: this endpoint cannot be simply called ``` constant} since it will conflict with
21922213
* other endpoints accepting an NdArray in parameter {e.g. [ #tensorOf(Scope, FloatNdArray)```
21932214
* ].
2194-
*
2215+
*
21952216
* @param scope is a scope used to add the underlying operation.
21962217
* @param tensor a Tensor holding the constant value
21972218
* @return a constant of the same data type as `tensor`
21982219
* @see org.tensorflow.op.Ops.constantOf
21992220
*/
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>(
22012222
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
22022241
)
22032242

22042243
/**
22052244
* This op consumes a lock created by `MutexLock`.
2206-
*
2245+
*
22072246
* This op exists to consume a tensor created by `MutexLock` (other than
22082247
* direct control dependencies). It should be the only that consumes the tensor,
22092248
* and will raise an error if it is not. Its only purpose is to keep the
22102249
* mutex lock tensor alive until it is consumed by this op.
2211-
*
2250+
*
22122251
* <b>NOTE</b>: This operation must run on the same device as its input. This may
22132252
* be enforced via the `colocate_with` mechanism.
22142253
*
@@ -4278,7 +4317,7 @@ public class KotlinOps(
42784317

42794318
/**
42804319
* Creates a one valued tensor given its type and shape.
4281-
*
4320+
*
42824321
* @param scope is a scope used to add the underlying operation
42834322
* @param dims a 1-D operand that represents the shape of the output tensor
42844323
* @param type the output tensor type class. Can not be TString.
@@ -4287,10 +4326,10 @@ public class KotlinOps(
42874326
* ones.
42884327
* @see org.tensorflow.op.Ops.ones
42894328
*/
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
42944333
)
42954334

42964335
/**
@@ -7558,22 +7597,97 @@ public class KotlinOps(
75587597
* <li>
75597598
* Adversarial training, where no backprop should happen through the adversarial
75607599
* example generation process.
7561-
*
7600+
*
75627601
* @param T data type for ` output()` output
75637602
* @param input
75647603
* @return a new instance of StopGradient
75657604
* @see org.tensorflow.op.Ops.stopGradient
75667605
*/
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>(
75687607
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&#91;i] for i in &#91;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
75697683
)
75707684

75717685
/**
75727686
* Return a strided slice from `input`.
7573-
*
7687+
*
75747688
* Note, most python users will want to use the Python `Tensor.__getitem__`
75757689
* or `Variable.__getitem__` rather than this op directly.
7576-
*
7690+
*
75777691
* The goal of this op is to produce a new tensor with a subset of
75787692
* the elements from the `n` dimensional `input` tensor. The subset is chosen using
75797693
* a sequence of `m` sparse range specifications encoded into the arguments
@@ -7714,21 +7828,52 @@ public class KotlinOps(
77147828
end,
77157829
strides,
77167830
*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) }
77227836
).toTypedArray()
7723-
)
7837+
)
77247838

77257839
/**
77267840
* 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+
*
77287873
* The values of `value` are assigned to the positions in the variable
77297874
* `ref` that are selected by the slice parameters. The slice parameters
77307875
* `begin`, `end`, `strides`, etc. work exactly as in `StridedSlice`.
7731-
*
7876+
*
77327877
* NOTE this op currently does not support broadcasting and so `value`'s
77337878
* shape must be exactly the shape produced by the slice of `ref`.
77347879
*
@@ -9927,7 +10072,7 @@ public class KotlinOps(
992710072

992810073
/**
992910074
* Creates a zeroed tensor given its type and shape.
9930-
*
10075+
*
993110076
* @param scope is a scope used to add the underlying operation
993210077
* @param dims a 1-D operand that represents the shape of the output tensor
993310078
* @param type the output tensor datatype
@@ -9936,10 +10081,10 @@ public class KotlinOps(
993610081
* zeros.
993710082
* @see org.tensorflow.op.Ops.zeros
993810083
*/
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
994310088
)
994410089

994510090
/**
@@ -10007,7 +10152,7 @@ public class KotlinOps(
1000710152
*
1000810153
* <i>NOTE</i>: Bitcast is implemented as a low-level cast, so machines with different
1000910154
* endian orderings will give different results.
10010-
*
10155+
*
1001110156
* @param U data type for ` output()` output
1001210157
* @param input
1001310158
* @param type
@@ -10016,11 +10161,29 @@ public class KotlinOps(
1001610161
*/
1001710162
@JvmName("bitcastReified")
1001810163
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)
1002010183

1002110184
/**
1002210185
* Create a constant with data from the given buffer.
10023-
*
10186+
*
1002410187
* @param T the tensor type
1002510188
* @param scope is a scope used to add the underlying operation.
1002610189
* @param type the tensor type class
@@ -10284,7 +10447,7 @@ public class KotlinOps(
1028410447

1028510448
/**
1028610449
* Creates a one valued tensor given its type and shape.
10287-
*
10450+
*
1028810451
* @param scope is a scope used to add the underlying operation
1028910452
* @param dims a 1-D operand that represents the shape of the output tensor
1029010453
* @param type the output tensor type class. Can not be TString.
@@ -10294,8 +10457,8 @@ public class KotlinOps(
1029410457
* @see org.tensorflow.op.Ops.ones
1029510458
*/
1029610459
@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)
1029910462

1030010463
/**
1030110464
* A placeholder op for a value that will be fed into the computation.
@@ -11030,7 +11193,7 @@ public class KotlinOps(
1103011193

1103111194
/**
1103211195
* Creates a zeroed tensor given its type and shape.
11033-
*
11196+
*
1103411197
* @param scope is a scope used to add the underlying operation
1103511198
* @param dims a 1-D operand that represents the shape of the output tensor
1103611199
* @param type the output tensor datatype
@@ -11040,6 +11203,6 @@ public class KotlinOps(
1104011203
* @see org.tensorflow.op.Ops.zeros
1104111204
*/
1104211205
@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)
1104511208
}

0 commit comments

Comments
 (0)