Skip to content

Commit 4bfee98

Browse files
committed
Codegen for reified type parameters
Signed-off-by: Ryan Nett <[email protected]>
1 parent 55f75ea commit 4bfee98

File tree

26 files changed

+9200
-6249
lines changed

26 files changed

+9200
-6249
lines changed

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,31 +176,30 @@
176176
<artifactId>maven-antrun-plugin</artifactId>
177177
<version>1.8</version>
178178
<executions>
179-
<execution>
180-
<id>ktlint-format</id>
179+
<!--<execution>
180+
<id>ktlint-format-generated</id>
181+
<phase>process-sources</phase>
181182
<configuration>
182183
<target name="ktlint">
183-
<java taskname="ktlint" dir="${basedir}" fork="true" failonerror="true"
184+
<java taskname="ktlint" dir="${basedir}" fork="false" failonerror="true"
184185
classpathref="maven.plugin.classpath" classname="com.pinterest.ktlint.Main">
185186
<arg value="-F"/>
186-
<arg value="src/**/*.kt"/>
187-
<arg value="--reporter=plain?group_by_file"/>
187+
<arg value="src/gen/**/*.kt"/>
188188
</java>
189189
</target>
190190
</configuration>
191191
<goals>
192192
<goal>run</goal>
193193
</goals>
194-
</execution>
194+
</execution>-->
195195
<execution>
196-
<id>ktlint-format-generated</id>
197-
<phase>process-sources</phase>
196+
<id>ktlint-format</id>
198197
<configuration>
199198
<target name="ktlint">
200-
<java taskname="ktlint" dir="${basedir}" fork="true" failonerror="true"
199+
<java taskname="ktlint" dir="${basedir}" fork="false" failonerror="true"
201200
classpathref="maven.plugin.classpath" classname="com.pinterest.ktlint.Main">
202201
<arg value="-F"/>
203-
<arg value="src/gen/**/*.kt"/>
202+
<arg value="src/**/*.kt"/>
204203
<arg value="--reporter=plain?group_by_file"/>
205204
</java>
206205
</target>
@@ -209,29 +208,29 @@
209208
<goal>run</goal>
210209
</goals>
211210
</execution>
212-
<execution>
211+
<!--<execution>
213212
<id>ktlint</id>
214213
<phase>process-sources</phase>
215214
<configuration>
216215
<target name="ktlint">
217-
<java taskname="ktlint" dir="${basedir}" fork="true" failonerror="true"
216+
<java taskname="ktlint" dir="${basedir}" fork="false" failonerror="true"
218217
classpathref="maven.plugin.classpath" classname="com.pinterest.ktlint.Main">
219218
<arg value="src/**/*.kt"/>
220219
<arg value="!src/gen/**/*.kt"/>
221-
<arg value="--reporter=plain?group_by_file"/>
220+
<arg value="&#45;&#45;reporter=plain?group_by_file"/>
222221
</java>
223222
</target>
224223
</configuration>
225224
<goals>
226225
<goal>run</goal>
227226
</goals>
228-
</execution>
227+
</execution>-->
229228
</executions>
230229
<dependencies>
231230
<dependency>
232231
<groupId>com.pinterest</groupId>
233232
<artifactId>ktlint</artifactId>
234-
<version>0.39.0</version>
233+
<version>0.40.0</version>
235234
</dependency>
236235
<!-- additional 3rd party ruleset(s) can be specified here -->
237236
</dependencies>

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

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,33 @@ public class AudioOps(
4747

4848
/**
4949
* Produces a visualization of audio data over time.
50-
*
50+
*
5151
* Spectrograms are a standard way of representing audio information as a series of
5252
* slices of frequency information, one slice for each window of time. By joining
5353
* these together into a sequence, they form a distinctive fingerprint of the sound
5454
* over time.
55-
*
55+
*
5656
* This op expects to receive audio data as an input, stored as floats in the range
5757
* -1 to 1, together with a window width in samples, and a stride specifying how
5858
* far to move the window between slices. From this it generates a three
5959
* dimensional output. The first dimension is for the channels in the input, so a
6060
* stereo audio input would have two here for example. The second dimension is time,
6161
* with successive frequency slices. The third dimension has an amplitude value for
6262
* each frequency during that time slice.
63-
*
63+
*
6464
* This means the layout when converted and saved as an image is rotated 90 degrees
6565
* clockwise from a typical spectrogram. Time is descending down the Y axis, and
6666
* the frequency decreases from left to right.
67-
*
67+
*
6868
* Each value in the result represents the square root of the sum of the real and
6969
* imaginary parts of an FFT on the current window of samples. In this way, the
7070
* lowest dimension represents the power of each frequency in the current window,
7171
* and adjacent windows are concatenated in the next dimension.
72-
*
72+
*
7373
* To get a more intuitive and visual look at what this operation does, you can run
7474
* tensorflow/examples/wav_to_spectrogram to read in an audio file and save out the
7575
* resulting spectrogram as a PNG image.
76-
*
76+
*
7777
* @param input Float representation of audio data.
7878
* @param windowSize How wide the input window is in samples. For the highest efficiency
7979
* this should be a power of two, but other values are accepted.
@@ -89,33 +89,33 @@ public class AudioOps(
8989
windowSize: Long,
9090
stride: Long,
9191
magnitudeSquared: Boolean? = null
92-
): AudioSpectrogram = java.audioSpectrogram(
92+
): AudioSpectrogram = java.audioSpectrogram(
9393
input,
9494
windowSize,
9595
stride,
9696
*listOfNotNull(
97-
magnitudeSquared?.let { org.tensorflow.op.audio.AudioSpectrogram.magnitudeSquared(it) }
97+
magnitudeSquared?.let{ org.tensorflow.op.audio.AudioSpectrogram.magnitudeSquared(it) }
9898
).toTypedArray()
99-
)
99+
)
100100

101101
/**
102102
* Decode a 16-bit PCM WAV file to a float tensor.
103-
*
103+
*
104104
* The -32768 to 32767 signed 16-bit values will be scaled to -1.0 to 1.0 in float.
105-
*
105+
*
106106
* When desired_channels is set, if the input contains fewer channels than this
107107
* then the last channel will be duplicated to give the requested number, else if
108108
* the input has more channels than requested then the additional channels will be
109109
* ignored.
110-
*
110+
*
111111
* If desired_samples is set, then the audio will be cropped or padded with zeroes
112112
* to the requested length.
113-
*
113+
*
114114
* The first output contains a Tensor with the content of the audio samples. The
115115
* lowest dimension will be the number of channels, and the second will be the
116116
* number of samples. For example, a ten-sample-long stereo WAV file should give an
117117
* output shape of &#91;10, 2].
118-
*
118+
*
119119
* @param contents The WAV-encoded audio, usually from a file.
120120
* @param options carries optional attributes values
121121
* @return a new instance of DecodeWav
@@ -127,47 +127,47 @@ public class AudioOps(
127127
contents: Operand<TString>,
128128
desiredChannels: Long? = null,
129129
desiredSamples: Long? = null
130-
): DecodeWav = java.decodeWav(
130+
): DecodeWav = java.decodeWav(
131131
contents,
132132
*listOfNotNull(
133-
desiredChannels?.let { org.tensorflow.op.audio.DecodeWav.desiredChannels(it) },
134-
desiredSamples?.let { org.tensorflow.op.audio.DecodeWav.desiredSamples(it) }
133+
desiredChannels?.let{ org.tensorflow.op.audio.DecodeWav.desiredChannels(it) },
134+
desiredSamples?.let{ org.tensorflow.op.audio.DecodeWav.desiredSamples(it) }
135135
).toTypedArray()
136-
)
136+
)
137137

138138
/**
139139
* Encode audio data using the WAV file format.
140-
*
140+
*
141141
* This operation will generate a string suitable to be saved out to create a .wav
142142
* audio file. It will be encoded in the 16-bit PCM format. It takes in float
143143
* values in the range -1.0f to 1.0f, and any outside that value will be clamped to
144144
* that range.
145-
*
145+
*
146146
* `audio` is a 2-D float Tensor of shape `&#91;length, channels]`.
147147
* `sample_rate` is a scalar Tensor holding the rate to use (e.g. 44100).
148-
*
148+
*
149149
* @param audio 2-D with shape `&#91;length, channels]`.
150150
* @param sampleRate Scalar containing the sample frequency.
151151
* @return a new instance of EncodeWav
152152
* @see org.tensorflow.op.AudioOps.encodeWav
153153
*/
154154
public fun encodeWav(audio: Operand<TFloat32>, sampleRate: Operand<TInt32>): EncodeWav =
155-
java.encodeWav(
156-
audio,
157-
sampleRate
155+
java.encodeWav(
156+
audio,
157+
sampleRate
158158
)
159159

160160
/**
161161
* Transforms a spectrogram into a form that's useful for speech recognition.
162-
*
162+
*
163163
* Mel Frequency Cepstral Coefficients are a way of representing audio data that's
164164
* been effective as an input feature for machine learning. They are created by
165165
* taking the spectrum of a spectrogram (a 'cepstrum'), and discarding some of the
166166
* higher frequencies that are less significant to the human ear. They have a long
167167
* history in the speech recognition world, and
168168
* https://en.wikipedia.org/wiki/Mel-frequency_cepstrum
169169
* is a good resource to learn more.
170-
*
170+
*
171171
* @param spectrogram Typically produced by the Spectrogram op, with magnitude_squared
172172
* set to true.
173173
* @param sampleRate How many samples per second the source audio used.
@@ -188,14 +188,14 @@ public class AudioOps(
188188
lowerFrequencyLimit: Float? = null,
189189
filterbankChannelCount: Long? = null,
190190
dctCoefficientCount: Long? = null
191-
): Mfcc = java.mfcc(
191+
): Mfcc = java.mfcc(
192192
spectrogram,
193193
sampleRate,
194194
*listOfNotNull(
195-
upperFrequencyLimit?.let { org.tensorflow.op.audio.Mfcc.upperFrequencyLimit(it) },
196-
lowerFrequencyLimit?.let { org.tensorflow.op.audio.Mfcc.lowerFrequencyLimit(it) },
197-
filterbankChannelCount?.let { org.tensorflow.op.audio.Mfcc.filterbankChannelCount(it) },
198-
dctCoefficientCount?.let { org.tensorflow.op.audio.Mfcc.dctCoefficientCount(it) }
195+
upperFrequencyLimit?.let{ org.tensorflow.op.audio.Mfcc.upperFrequencyLimit(it) },
196+
lowerFrequencyLimit?.let{ org.tensorflow.op.audio.Mfcc.lowerFrequencyLimit(it) },
197+
filterbankChannelCount?.let{ org.tensorflow.op.audio.Mfcc.filterbankChannelCount(it) },
198+
dctCoefficientCount?.let{ org.tensorflow.op.audio.Mfcc.dctCoefficientCount(it) }
199199
).toTypedArray()
200-
)
200+
)
201201
}

0 commit comments

Comments
 (0)