Skip to content

Commit 111ee68

Browse files
committed
Initial framework wrappers
Signed-off-by: Ryan Nett <[email protected]>
1 parent 6100799 commit 111ee68

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

tensorflow-kotlin-parent/tensorflow-framework-kotlin/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
<artifactId>tensorflow-framework</artifactId>
4141
<version>${project.version}</version>
4242
</dependency>
43+
<dependency>
44+
<groupId>org.tensorflow</groupId>
45+
<artifactId>tensorflow-core-kotlin</artifactId>
46+
<version>${project.version}</version>
47+
</dependency>
4348
<dependency>
4449
<groupId>org.junit.jupiter</groupId>
4550
<artifactId>junit-jupiter-api</artifactId>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
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+
17+
*/
18+
package org.tensorflow.framework.activations
19+
20+
import org.tensorflow.Operand
21+
import org.tensorflow.op.kotlin.KotlinOps
22+
import org.tensorflow.op.kotlin.kotlin
23+
import org.tensorflow.types.family.TNumber
24+
25+
/**
26+
* Create an initializer.
27+
* @see org.tensorflow.framework.activations.Activation
28+
*/
29+
public inline fun <T : TNumber> Activation(
30+
crossinline activation: KotlinOps.(Operand<T>) -> Operand<T>
31+
): Activation<T> =
32+
org.tensorflow.framework.activations.Activation { tf, input -> activation(tf.kotlin, input) }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
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+
17+
*/
18+
package org.tensorflow.framework.initializers
19+
20+
import org.tensorflow.Operand
21+
import org.tensorflow.op.Ops
22+
import org.tensorflow.op.kotlin.KotlinOps
23+
import org.tensorflow.op.kotlin.kotlin
24+
import org.tensorflow.types.TInt64
25+
import org.tensorflow.types.family.TType
26+
27+
/**
28+
* Create an initializer
29+
* @see org.tensorflow.framework.initializers.Initializer
30+
*/
31+
public inline fun <T : TType> Initializer(crossinline initializer: KotlinOps.(dims: Operand<TInt64>, dataType: Class<T>) -> Operand<T>): Initializer<T> =
32+
org.tensorflow.framework.initializers.Initializer { tf, dims, dataType ->
33+
initializer(tf.kotlin, dims, dataType)
34+
}
35+
36+
/**
37+
* Call an initializer.
38+
*/
39+
public inline fun <reified T: TType> Initializer<T>.call(tf: Ops, dims: Operand<TInt64>): Operand<T> = call(tf, dims, T::class.java)!!

0 commit comments

Comments
 (0)