Skip to content

Commit 772f675

Browse files
committed
Add section in CONTRIBUTING
Signed-off-by: Ryan Nett <[email protected]>
1 parent a879da8 commit 772f675

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

CONTRIBUTING.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ For dependencies, we can use anything compliant with [this list](https://opensou
9494

9595
### Code generation
9696

97-
Code generation for `Ops` and related classes is done during `tensorflow-core-api`'s `compile` phase, using the annotation processor in
98-
`tensorflow-core-generator`. If you change or add any operator classes (annotated with `org.tensorflow.op.annotation.Operator`), endpoint methods (
99-
annotated with `org.tensorflow.op.annotation.Endpoint`), or change the annotation processor, be sure to re-run a
100-
`mvn install` in `tensorflow-core-api` (`-Pdev` is fine for this, it just needs to run the annotation processor).
97+
Code generation for `Ops` and related classes is done during `tensorflow-core-api` and `tensorflow-core-kotlin`'s `compile` phase,
98+
using the annotation processors in `tensorflow-core-generator` and `tensorflow-kotlin-generator`, respectively. If you change or add any
99+
operator classes (annotated with `org.tensorflow.op.annotation.Operator`), endpoint methods (annotated with `org.tensorflow.op.annotation.Endpoint`),
100+
or change the annotation processor, be sure to re-run a `mvn compile` in `tensorflow-core-api` **and** `tensorflow-core-kotlin`
101+
(`-Pdev` is fine for this, it just needs to run the annotation processor).
101102

102103
### Working with Bazel generation
103104

@@ -113,6 +114,20 @@ bazel-out/k8-opt/bin/external/org_tensorflow/tensorflow/libtensorflow_cc.so --ou
113114

114115
(called in `tensorflow-core-api`).
115116

117+
### Kotlin API
118+
119+
The Kotlin api should be kept to a thin wrapper of the Java API, using extension functions and codegen wherever possible.
120+
We do not want to get into a situation where we are maintaining two separate but related APIs.
121+
122+
The codegen (`tensorflow-core-kotlin-generator`) is an annotation processor that reads the `@Operator` classes from the `tensorflow-core-api` Java sources.
123+
If you add operators or re-generate them from the native library, be sure to re-run a `mvn install` in `tensorflow-core-kotlin-api`.
124+
125+
#### Formatting
126+
127+
The Kotlin API is formatted with ktlint, which is ran on build.
128+
The build will not auto-format non-generated files.
129+
You can format them by installing ktlint as the IDE format and using its formatter, or by running `mvn antrun:run@ktlint-format`.
130+
116131
## Adding Gradients
117132

118133
In some cases, a op supported by Tensorflow Java will not have a gradient defined, resulting in errors like this:

0 commit comments

Comments
 (0)