Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ gradleBuild
# Deployment Files
settings.xml
pom.xml.asc

# Docs
docs/docs/apidocs/
Empty file modified docs/_toc.yaml
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions docs/docs/assets/tensorflow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 11 additions & 22 deletions docs/index.md → docs/docs/index.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# TensorFlow for Java

<table class="tfo-notebook-buttons" align="left">
<td>
<a target="_blank" href="https://www.tensorflow.org/jvm"><img src="https://www.tensorflow.org/images/tf_logo_32px.png" />View on TensorFlow.org</a>
</td>
<td>
<a target="_blank" href="https://github.com/tensorflow/java"><img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />View GitHub repository</a>
</td>
</table>

TensorFlow Java can run on any JVM for building, training and running machine learning models. It comes with
a series of utilities and frameworks that help achieve most of the tasks common to data scientists
and developers working in this domain. Java and other JVM languages, such as Scala or Kotlin, are
Expand All @@ -26,21 +17,19 @@ migrated from Bazel to Maven, which is more familiar for most Java developers.

The following describes the layout of the repository and its different artifacts:

* [tensorflow-core](https://github.com/tensorflow/java/tree/master/tensorflow-core)
* All artifacts that build up the core language bindings of TensorFlow for Java
* Intended audience: projects that provide their own APIs or frameworks on top of
TensorFlow and just want a thin layer to access the TensorFlow runtime from the JVM

* [tensorflow-framework](https://github.com/tensorflow/java/tree/master/tensorflow-framework)
* Primary API for building and training neural networks with TensorFlow
* Intended audience: neural network developers
### [tensorflow-core](https://github.com/tensorflow/java/tree/master/tensorflow-core)
* **Intended audience**: developers who wants to deploy a TensorFlow model on a JVM for inference. Also for projects
that provide their own APIs or frameworks on top of TensorFlow and just want a thin layer to access the TensorFlow runtime from the JVM.
* All artifacts that make up the core language bindings of TensorFlow for Java.

* [ndarray](https://github.com/tensorflow/java-ndarray)
* Generic utility library for n-dimensional data I/O operations
* Used by TensorFlow but does not depend on TensorFlow
* Intended audience: any developer who needs a Java n-dimensional array implementation, whether or not they
use it with TensorFlow
### [tensorflow-framework](https://github.com/tensorflow/java/tree/master/tensorflow-framework)
* **Intended audience**: neural network developers.
* Primary API for building and training neural networks with TensorFlow.

### [ndarray](https://github.com/tensorflow/java-ndarray)
* **Intended audience**: any developer who needs a Java n-dimensional array implementation, whether or not they use it with TensorFlow.
* Generic utility library for n-dimensional data I/O operations.
* Used by TensorFlow but does not depend on TensorFlow.

## Communication

Expand Down
2 changes: 1 addition & 1 deletion docs/install.md → docs/docs/install.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TensorFlow Java 1.0 series and earlier releases also have binaries for:
* macOS 12 or higher; 64-bit, x86

*Note: To use TensorFlow on Android, see
[TensorFlow Lite](https://tensorflow.org/lite)*
[TensorFlow LiteRT](https://tensorflow.org/lite)*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's just called LiteRT now, they dropped the TensorFlow.


## Versions

Expand Down
8 changes: 8 additions & 0 deletions docs/docs/references.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
hide:
- navigation
- toc
- title
---
#
<iframe src="https://tensorflow.github.io/java/javadoc/v1.2.0/index.html" style="width:100%; height:800px; border:none;"></iframe>
14 changes: 14 additions & 0 deletions docs/docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
:root > * {
/*--md-primary-fg-color: #EE782F;*/
/*--md-primary-fg-color--light: #455960;*/
/*--md-primary-fg-color--dark: #90030C;*/
}

.md-typeset h1, .md-typeset h2 {
font-weight: 800;
letter-spacing: -.01em;
}

.md-sidebar--primary {
display: none;
}
97 changes: 97 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
site_name: ''
site_url: https://tensorflow.org
repo_url: https://github.com/tensorflow/java
site_description: Documentation of TensorFlow Java API and tools.
copyright: "&copy; TensorFlow Authors 2025"

theme:
name: material
logo: assets/tensorflow.svg
features:
- navigation.indexes
- navigation.instant
- navigation.sections
- navigation.tabs
- navigation.tabs.sticky
- toc.follow
palette:
# Palette toggle for automatic mode
- media: "(prefers-color-scheme)"
toggle:
icon: material/brightness-auto
name: Switch to light mode
# Palette toggle for light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: white
accent: orange
toggle:
icon: material/brightness-7
name: Switch to dark mode
# Palette toggle for dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: black
accent: orange
toggle:
icon: material/brightness-4
name: Switch to system preference

extra_css:
- stylesheets/extra.css

nav:
- Home:
- index.md
- Install:
- install.md
- References:
- apidocs/index.html

#markdown_extensions:
# - admonition
# - pymdownx.snippets
# - pymdownx.superfences
# - pymdownx.details
# - pymdownx.superfences
# - attr_list
# - md_in_html
# - toc
# - pymdownx.tabbed:
# alternate_style: true

#plugins:
# - search
# - glightbox
# - include-markdown
# - include_dir_to_nav
# - mkdocs-jupyter:
# execute: false
# include_source: true
# - mkdocstrings:
# default_handler: python
# handlers:
# python:
# load_external_modules: false
# options:
# docstring_options:
# ignore_init_summary: true
# docstring_style: google
# members_order: source
# merge_init_into_class: true
# parameter_headings: true
# separate_signature: true
# show_if_no_docstring: true
# show_root_full_path: true
# show_root_heading: false
# show_source: true
# show_symbol_type_heading: true
# show_symbol_type_toc: true
# signature_crossrefs: true
#
#extra:
# generator: false
# social:
# - icon: fontawesome/brands/slack
# link: https://expediagroup.enterprise.slack.com/archives/C08RD5SBRLH
# name: "#ask-genai-platform"
125 changes: 125 additions & 0 deletions docs/tools/build_java_api_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Lint as: python3
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Generate TensorFlow Java reference docs for TensorFlow.org."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import pathlib
import shutil
import tempfile
import io
import requests
import zipfile
from git import Repo

from absl import app
from absl import flags

from tensorflow_docs.api_generator import gen_java

FLAGS = flags.FLAGS

NDARRAY_VERSION = 'v1.0.0'
JAVACPP_VERSION = '1.5.11'
PROTOBUF_VERSION = 'v3.21.9'

# __file__ is the path to this file
TOOLS_DIR = pathlib.Path(__file__).resolve().parent
DOCS_DIR = TOOLS_DIR.parent
REPO_ROOT = DOCS_DIR.parent
DOC_OUTPUT_DIR = DOCS_DIR.joinpath("output")

SECTION_LABELS = {
'org.tensorflow': 'Core',
'org.tensorflow.ndarray': 'NdArray',
'org.tensorflow.framework': 'Framework',
}

# These flags are required by infrastructure, not all of them are used.
flags.DEFINE_string('output_dir', f"{DOC_OUTPUT_DIR}",
("Use this branch as the root version and don't"
' create in version directory'))

flags.DEFINE_string('site_path', 'api_docs/',
'Path prefix in the _toc.yaml')

flags.DEFINE_string('code_url_prefix', None,
'[UNUSED] The url prefix for links to code.')

flags.DEFINE_bool(
'search_hints', True,
'[UNUSED] Include metadata search hints in the generated files')


def checkout_repo(repo_url: str, target_dir_name: str, version: str):
local_repo_path = f"{REPO_ROOT}/{target_dir_name}"
if not pathlib.Path(local_repo_path).exists():
local_repo = Repo.clone_from(repo_url, local_repo_path)
else:
local_repo = Repo(local_repo_path)
local_repo.remotes['origin'].fetch()
local_repo.git.checkout(version)


def overlay(from_root, to_root):
for from_path in pathlib.Path(from_root).rglob('*'):
relpath = from_path.relative_to(from_root)
to_path = to_root/relpath
if from_path.is_file():
assert not to_path.exists()
shutil.copyfile(from_path, to_path)
else:
to_path.mkdir(exist_ok=True)


def main(unused_argv):
checkout_repo('https://github.com/tensorflow/java-ndarray', 'ndarray', NDARRAY_VERSION)
checkout_repo('https://github.com/bytedeco/javacpp', 'javacpp', JAVACPP_VERSION)
response = requests.get('https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/3.21.9/protobuf-java-3.21.9-sources.jar')
with zipfile.ZipFile(io.BytesIO(response.content)) as z:
z.extractall(f"{REPO_ROOT}/protobuf")
response = requests.get('https://repo1.maven.org/maven2/org/osgi/osgi.annotation/8.1.0/osgi.annotation-8.1.0-sources.jar')
with zipfile.ZipFile(io.BytesIO(response.content)) as z:
z.extractall(f"{REPO_ROOT}/osgi")

merged_source = pathlib.Path(tempfile.mkdtemp())
(merged_source / 'java/org').mkdir(parents=True)
shutil.copytree(REPO_ROOT/'tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/', merged_source/'java/org/tensorflow')
overlay(REPO_ROOT/'tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow', merged_source/'java/org/tensorflow')
overlay(REPO_ROOT/'tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow', merged_source/'java/org/tensorflow')
overlay(REPO_ROOT/'tensorflow-core/tensorflow-core-native/src/gen/java/org/tensorflow/', merged_source/'java/org/tensorflow/')
overlay(REPO_ROOT/'tensorflow-core/tensorflow-core-native/src/main/java/org/tensorflow/', merged_source/'java/org/tensorflow/')
shutil.copytree(REPO_ROOT/'tensorflow-framework/src/main/java/org/tensorflow/framework', merged_source/'java/org/tensorflow/framework')
shutil.copytree(REPO_ROOT/'ndarray/ndarray/src/main/java/org/tensorflow/ndarray', merged_source/'java/org/tensorflow/ndarray')
shutil.copytree(REPO_ROOT/'javacpp/src/main/java/org/bytedeco', merged_source/'java/org/bytedeco')
shutil.copytree(REPO_ROOT/'protobuf/com/', merged_source/'java/com')
shutil.copytree(REPO_ROOT/'osgi/org/osgi', merged_source/'java/org/osgi')

gen_java.gen_java_docs(
package='org.tensorflow',
source_path=merged_source / 'java',
output_dir=pathlib.Path(FLAGS.output_dir),
site_path=pathlib.Path(FLAGS.site_path),
section_labels=SECTION_LABELS,
# Uncomment for local testing:
script_path=pathlib.Path(TOOLS_DIR, 'run-javadoc-for-tf-local.sh'),
)


if __name__ == '__main__':
flags.mark_flags_as_required(['output_dir'])
app.run(main)
Loading
Loading