11/*
2- Copyright 2021 The TensorFlow Authors. All Rights Reserved.
3-
4- Licensed under the Apache License, Version 2.0 (the "License");
5- you may not use this file except in compliance with the License.
6- You may obtain a copy of the License at
7-
8- http://www.apache.org/licenses/LICENSE-2.0
9-
10- Unless required by applicable law or agreed to in writing, software
11- distributed under the License is distributed on an "AS IS" BASIS,
12- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- See the License for the specific language governing permissions and
14- limitations under the License.
15- ==============================================================================
16- */
2+ Copyright 2021 The TensorFlow Authors. All Rights Reserved.
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ ==============================================================================
16+ */
1717package org.tensorflow
1818
19- import org.tensorflow.op.kotlin.KotlinOps
20- import org.tensorflow.op.kotlin.kotlin
2119import kotlin.contracts.InvocationKind
2220import kotlin.contracts.contract
21+ import org.tensorflow.op.kotlin.KotlinOps
22+ import org.tensorflow.op.kotlin.kotlin
2323
2424/* *
2525 * Create a [ConcreteFunction] by building a new graph.
2626 * @see ConcreteFunction.create
2727 */
28- public inline fun ConcreteFunction (crossinline function : KotlinOps .() -> Signature ): ConcreteFunction {
29- contract { callsInPlace(function, InvocationKind .EXACTLY_ONCE ) }
30- return ConcreteFunction .create { function(it.kotlin) }
28+ public inline fun ConcreteFunction (
29+ crossinline function : KotlinOps .() -> Signature
30+ ): ConcreteFunction {
31+ contract { callsInPlace(function, InvocationKind .EXACTLY_ONCE ) }
32+ return ConcreteFunction .create { function(it.kotlin) }
3133}
3234
3335/* *
3436 * Call this function with the specified arguments.
3537 * @see ConcreteFunction.call
3638 */
37- public operator fun ConcreteFunction.invoke (arguments : Map <String , Tensor >): Map <String , Tensor > = this .call(arguments)
39+ public operator fun ConcreteFunction.invoke (arguments : Map <String , Tensor >): Map <String , Tensor > =
40+ this .call(arguments)
3841
3942/* *
4043 * Call this function with the specified arguments.
4144 * @see ConcreteFunction.call
4245 */
43- public operator fun ConcreteFunction.invoke (vararg arguments : Pair <String , Tensor >): Map <String , Tensor > =
44- this .invoke(arguments.toMap())
46+ public operator fun ConcreteFunction.invoke (
47+ vararg arguments : Pair <String , Tensor >
48+ ): Map <String , Tensor > = this .invoke(arguments.toMap())
4549
4650/* *
47- * Call this function with a single argument. Requires this function to be a single argument function.
51+ * Call this function with a single argument. Requires this function to be a single argument
52+ * function.
4853 * @see ConcreteFunction.call
4954 */
5055public operator fun ConcreteFunction.invoke (argument : Tensor ): Tensor = this .call(argument)
5156
52- /* *
53- * Create a [Signature] for a [ConcreteFunction].
54- */
57+ /* * Create a [Signature] for a [ConcreteFunction]. */
5558public fun Signature (
5659 methodName : String ,
5760 inputs : Map <String , Operand <* >>,
@@ -60,64 +63,62 @@ public fun Signature(
6063): Signature =
6164 Signature .builder().methodName(methodName).key(key).inputs(inputs).outputs(outputs).build()
6265
63- /* *
64- * Create a [Signature] for a [ConcreteFunction].
65- */
66+ /* * Create a [Signature] for a [ConcreteFunction]. */
6667public fun Signature (
6768 methodName : String ,
6869 inputs : Operand <* >,
6970 outputs : Map <String , Operand <* >>,
7071 key : String = Signature .DEFAULT_KEY ,
7172): Signature =
72- Signature .builder().methodName(methodName).key(key).input(" input" , inputs).outputs(outputs).build()
73+ Signature .builder()
74+ .methodName(methodName)
75+ .key(key)
76+ .input(" input" , inputs)
77+ .outputs(outputs)
78+ .build()
7379
74- /* *
75- * Create a [Signature] for a [ConcreteFunction].
76- */
80+ /* * Create a [Signature] for a [ConcreteFunction]. */
7781public fun Signature (
7882 methodName : String ,
7983 inputs : Map <String , Operand <* >>,
8084 outputs : Operand <* >,
8185 key : String = Signature .DEFAULT_KEY ,
8286): Signature =
83- Signature .builder().methodName(methodName).key(key).inputs(inputs).output(" output" , outputs).build()
87+ Signature .builder()
88+ .methodName(methodName)
89+ .key(key)
90+ .inputs(inputs)
91+ .output(" output" , outputs)
92+ .build()
8493
85- /* *
86- * Create a [Signature] for a [ConcreteFunction].
87- */
94+ /* * Create a [Signature] for a [ConcreteFunction]. */
8895public fun Signature (
8996 methodName : String ,
9097 inputs : Operand <* >,
9198 outputs : Operand <* >,
9299 key : String = Signature .DEFAULT_KEY ,
93100): Signature =
94- Signature .builder().methodName(methodName).key(key).input(" input" , inputs).output(" output" , outputs).build()
101+ Signature .builder()
102+ .methodName(methodName)
103+ .key(key)
104+ .input(" input" , inputs)
105+ .output(" output" , outputs)
106+ .build()
95107
96- /* *
97- * Add [inputs] to the signature.
98- */
108+ /* * Add [inputs] to the signature. */
99109public fun Signature.Builder.inputs (inputs : Map <String , Operand <* >>): Signature .Builder = apply {
100- inputs.forEach {
101- input(it.key, it.value)
102- }
110+ inputs.forEach { input(it.key, it.value) }
103111}
104112
105- /* *
106- * Add [outputs] to the signature.
107- */
113+ /* * Add [outputs] to the signature. */
108114public fun Signature.Builder.outputs (outputs : Map <String , Operand <* >>): Signature .Builder = apply {
109- outputs.forEach {
110- output(it.key, it.value)
111- }
115+ outputs.forEach { output(it.key, it.value) }
112116}
113117
114- /* *
115- * Add [inputs] to the signature.
116- */
117- public fun Signature.Builder.inputs (vararg inputs : Pair <String , Operand <* >>): Signature .Builder = inputs(inputs.toMap())
118+ /* * Add [inputs] to the signature. */
119+ public fun Signature.Builder.inputs (vararg inputs : Pair <String , Operand <* >>): Signature .Builder =
120+ inputs(inputs.toMap())
118121
119- /* *
120- * Add [outputs] to the signature.
121- */
122+ /* * Add [outputs] to the signature. */
122123public fun Signature.Builder.outputs (vararg outputs : Pair <String , Operand <* >>): Signature .Builder =
123124 outputs(outputs.toMap())
0 commit comments