Skip to content

Commit 36adff0

Browse files
committed
Initial kotlin generation (still using Options), some helpers
Signed-off-by: Ryan Nett <rnett@calpoly.edu>
1 parent b0b0927 commit 36adff0

File tree

28 files changed

+7022
-31
lines changed

28 files changed

+7022
-31
lines changed

tensorflow-core-kotlin/tensorflow-core-kotlin-api/pom.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@
8888
<groupId>org.jetbrains.kotlin</groupId>
8989
<artifactId>kotlin-maven-plugin</artifactId>
9090
<version>${kotlin.version}</version>
91+
<configuration>
92+
<args>
93+
<arg>-Xopt-in=kotlin.contracts.ExperimentalContracts</arg>
94+
<arg>-Xexplicit-api=strict</arg>
95+
</args>
96+
</configuration>
9197

9298
<executions>
9399
<execution>
@@ -97,9 +103,10 @@
97103
</goals>
98104
<configuration>
99105
<sourceDirs>
100-
<!-- <sourceDir>${project.basedir}/../../tensorflow-core/tensorflow-core-api/src/gen/java</sourceDir>-->
101-
<!-- <sourceDir>${project.basedir}/../../tensorflow-core/tensorflow-core-api/src/gen/annotations</sourceDir>-->
102-
<!-- <sourceDir>${project.basedir}/../../tensorflow-core/tensorflow-core-api/src/main/java</sourceDir>-->
106+
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
107+
<sourceDir>${project.basedir}/../../tensorflow-core/tensorflow-core-api/src/gen/java</sourceDir>
108+
<sourceDir>${project.basedir}/../../tensorflow-core/tensorflow-core-api/src/gen/annotations</sourceDir>
109+
<sourceDir>${project.basedir}/../../tensorflow-core/tensorflow-core-api/src/main/java</sourceDir>
103110
</sourceDirs>
104111
<annotationProcessors>
105112
<annotationProcessor>org.tensorflow.processor.operator.KotlinOpsProcessor</annotationProcessor>
@@ -108,7 +115,7 @@
108115
<!-- Specify your annotation processors here. -->
109116
<annotationProcessorPath>
110117
<groupId>org.tensorflow</groupId>
111-
<!-- <artifactId>tensorflow-core-kotlin-generator</artifactId>-->
118+
<artifactId>tensorflow-core-kotlin-generator</artifactId>
112119
<version>${project.version}</version>
113120
</annotationProcessorPath>
114121
</annotationProcessorPaths>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// ==============================================================================
15+
//
16+
// This class has been generated, DO NOT EDIT!
17+
//
18+
package org.tensorflow.op.kotlin
19+
20+
import org.tensorflow.Operand
21+
import org.tensorflow.op.Scope
22+
import org.tensorflow.op.audio.AudioSpectrogram
23+
import org.tensorflow.op.audio.DecodeWav
24+
import org.tensorflow.op.audio.EncodeWav
25+
import org.tensorflow.op.audio.Mfcc
26+
import org.tensorflow.types.TFloat32
27+
import org.tensorflow.types.TInt32
28+
import org.tensorflow.types.TString
29+
30+
/**
31+
* An API for building {@code audio} operations as {@link org.tensorflow.op.Op Op}s
32+
*
33+
* @see {@link org.tensorflow.op.Ops}
34+
*/
35+
public class AudioOps(
36+
/**
37+
* Get the parent {@link KotlinOps} object.
38+
*/
39+
public val ops: KotlinOps
40+
) {
41+
public val java: org.tensorflow.op.AudioOps = ops.java.audio
42+
43+
/**
44+
* Returns the current {@link Scope scope} of this API
45+
*/
46+
public val scope: Scope = ops.scope
47+
48+
public fun audioSpectrogram(
49+
input: Operand<TFloat32>,
50+
windowSize: Long,
51+
stride: Long,
52+
vararg options: AudioSpectrogram.Options
53+
): AudioSpectrogram = java.audioSpectrogram(input, windowSize, stride, *options)
54+
55+
public fun decodeWav(contents: Operand<TString>, vararg options: DecodeWav.Options): DecodeWav =
56+
java.decodeWav(contents, *options)
57+
58+
public fun encodeWav(audio: Operand<TFloat32>, sampleRate: Operand<TInt32>): EncodeWav =
59+
java.encodeWav(audio, sampleRate)
60+
61+
public fun mfcc(
62+
spectrogram: Operand<TFloat32>,
63+
sampleRate: Operand<TInt32>,
64+
vararg options: Mfcc.Options
65+
): Mfcc = java.mfcc(spectrogram, sampleRate, *options)
66+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// ==============================================================================
15+
//
16+
// This class has been generated, DO NOT EDIT!
17+
//
18+
package org.tensorflow.op.kotlin
19+
20+
import org.tensorflow.Operand
21+
import org.tensorflow.op.Scope
22+
import org.tensorflow.op.bitwise.BitwiseAnd
23+
import org.tensorflow.op.bitwise.BitwiseOr
24+
import org.tensorflow.op.bitwise.BitwiseXor
25+
import org.tensorflow.op.bitwise.Invert
26+
import org.tensorflow.op.bitwise.LeftShift
27+
import org.tensorflow.op.bitwise.RightShift
28+
import org.tensorflow.types.family.TNumber
29+
30+
/**
31+
* An API for building {@code bitwise} operations as {@link org.tensorflow.op.Op Op}s
32+
*
33+
* @see {@link org.tensorflow.op.Ops}
34+
*/
35+
public class BitwiseOps(
36+
/**
37+
* Get the parent {@link KotlinOps} object.
38+
*/
39+
public val ops: KotlinOps
40+
) {
41+
public val java: org.tensorflow.op.BitwiseOps = ops.java.bitwise
42+
43+
/**
44+
* Returns the current {@link Scope scope} of this API
45+
*/
46+
public val scope: Scope = ops.scope
47+
48+
public fun <T : TNumber> bitwiseAnd(x: Operand<T>, y: Operand<T>): BitwiseAnd<T> =
49+
java.bitwiseAnd<T>(x, y)
50+
51+
public fun <T : TNumber> bitwiseOr(x: Operand<T>, y: Operand<T>): BitwiseOr<T> =
52+
java.bitwiseOr<T>(x, y)
53+
54+
public fun <T : TNumber> bitwiseXor(x: Operand<T>, y: Operand<T>): BitwiseXor<T> =
55+
java.bitwiseXor<T>(x, y)
56+
57+
public fun <T : TNumber> invert(x: Operand<T>): Invert<T> = java.invert<T>(x)
58+
59+
public fun <T : TNumber> leftShift(x: Operand<T>, y: Operand<T>): LeftShift<T> =
60+
java.leftShift<T>(x, y)
61+
62+
public fun <T : TNumber> rightShift(x: Operand<T>, y: Operand<T>): RightShift<T> =
63+
java.rightShift<T>(x, y)
64+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// ==============================================================================
15+
//
16+
// This class has been generated, DO NOT EDIT!
17+
//
18+
package org.tensorflow.op.kotlin
19+
20+
import org.tensorflow.DataType
21+
import org.tensorflow.Operand
22+
import org.tensorflow.ndarray.Shape
23+
import org.tensorflow.op.Scope
24+
import org.tensorflow.op.`data`.experimental.DataServiceDataset
25+
import org.tensorflow.types.TInt64
26+
import org.tensorflow.types.TString
27+
28+
/**
29+
* An API for building {@code data.experimental} operations as {@link org.tensorflow.op.Op Op}s
30+
*
31+
* @see {@link org.tensorflow.op.Ops}
32+
*/
33+
public class DataExperimentalOps(
34+
/**
35+
* Get the parent {@link KotlinOps} object.
36+
*/
37+
public val ops: KotlinOps
38+
) {
39+
public val java: org.tensorflow.op.DataExperimentalOps = ops.java.data.experimental
40+
41+
/**
42+
* Returns the current {@link Scope scope} of this API
43+
*/
44+
public val scope: Scope = ops.scope
45+
46+
public fun dataServiceDataset(
47+
datasetId: Operand<TInt64>,
48+
processingMode: Operand<TString>,
49+
address: Operand<TString>,
50+
protocol: Operand<TString>,
51+
jobName: Operand<TString>,
52+
maxOutstandingRequests: Operand<TInt64>,
53+
iterationCounter: Operand<*>,
54+
outputTypes: List<DataType<*>>,
55+
outputShapes: List<Shape>,
56+
vararg options: DataServiceDataset.Options
57+
): DataServiceDataset = java.dataServiceDataset(datasetId, processingMode, address, protocol,
58+
jobName, maxOutstandingRequests, iterationCounter, outputTypes, outputShapes, *options)
59+
}

0 commit comments

Comments
 (0)