Open-Source Wikis

/

TensorFlow

/

How to contribute

/

Tooling

tensorflow/tensorflow

Tooling

The build system, code generators, and supporting scripts.

Bazel

Bazel is the only blessed build system. Important pieces:

  • WORKSPACE and MODULE.bazel — repo-level dependencies. The transition from WORKSPACE to bzlmod is partial; both files are still active.
  • .bazelrc (~60 KB) — the project's default flag set. Defines --config=cuda, --config=rocm, --config=xla_cpu, --config=tflite_with_xnnpack, --config=asan, --config=msan, --config=tsan, --config=opt, --config=mkl.
  • .bazelignore and .bazelversion.
  • tensorflow/tensorflow.bzl — the project's central macro library (~130 KB). It defines tf_cc_library, tf_kernel_library, tf_py_test, tf_proto_library, tf_cuda_cc_test, etc. Almost every BUILD file in the repo calls into it.
  • tensorflow/tensorflow.default.bzl, tensorflow/tf_version.bzl, tensorflow/strict.default.bzl, tensorflow/pytype.default.bzl — auxiliary toggles.

For day-to-day work, bazelisk (any version) is fine — it reads .bazelversion and downloads the right Bazel automatically.

./configure

The top-level ./configure script is a thin wrapper around configure.py (~50 KB). It writes .tf_configure.bazelrc based on:

  • Python interpreter path (PYTHON_BIN_PATH).
  • CUDA support (TF_NEED_CUDA, TF_CUDA_PATHS, TF_CUDA_VERSION, TF_CUDNN_VERSION).
  • ROCm support (TF_NEED_ROCM).
  • TensorRT support (TF_NEED_TENSORRT).
  • MPI support, MKL support, monolithic build, build optimization flags, Android build settings.

For unattended builds, set the env vars and run ./configure non-interactively. CI uses pre-built Docker images that bake in answers (ci/official/).

Code generation

  • Op wrapperstensorflow/python/ops/gen_*.py. Generated by Bazel rule tf_gen_op_wrapper_py (in tensorflow.bzl) from OpDef registrations. The generator binary lives in tensorflow/python/framework/python_op_gen_main.cc.
  • C++ opstensorflow/cc/ops/*.h,cc produced by tf_gen_op_wrappers_cc for each op family (tensorflow/core/ops/). Resulting headers expose MatMul(...), Add(...), etc., as a builder API for C++.
  • Python API stubstensorflow/api_template.__init__.py and tensorflow/api_template_v1.__init__.py are templates. Bazel rule gen_api_init_files_py (tensorflow/tools/api/) walks @tf_export(...) decorators and produces the full tensorflow/_api/v2/ tree at build time.
  • Protobufstensorflow/core/protobuf/*.proto, tensorflow/core/framework/*.proto. Generated *_pb2.py files for Python; C++ generated headers in bazel-bin/.
  • FlatBufferstensorflow/lite/schema/schema.fbs, tensorflow/lite/schema/conversion_metadata.fbs. Generated *.h for C++ and *.py for Python.

Don't edit any gen_*.py or *_pb2.py by hand.

Lint

  • C++: clang-format (config .clang-format).
  • Python: pylint (config tensorflow/tools/ci_build/pylintrc, root symlink .pylintrc).
  • Bazel: buildifier.
  • Markdown: light style only; some directories run mdformat in CI.

Doc generation

  • API docs are generated by tensorflow/tools/docs/.
  • The generator emits Markdown the tensorflow/docs repo (separate) renders.
  • tensorflow/lite/g3doc/ and tensorflow/python/keras/ (legacy) keep small in-tree doc trees.

CI scripts

  • ci/official/ — the modern CI configurations and docker images. Subdirectories per platform (linux_x86, linux_arm64, macos_arm64, windows, …).
  • ci/devinfra/ — internal scripts (some only meaningful inside Google).
  • .github/workflows/ — GitHub Actions for PR-side checks (formatting, basic builds, license/CLA).

The tensorflow/tools/ directory has older but still-used helpers:

Path Purpose
tensorflow/tools/pip_package/ Pip wheel build rule (//tensorflow/tools/pip_package:wheel).
tensorflow/tools/api/ API export and golden-file checks.
tensorflow/tools/docs/ Docs generator + tag scrubber.
tensorflow/tools/test/ CI helpers and benchmarks.
tensorflow/tools/git/ Git utilities used by versioncontrol_utils.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Tooling – TensorFlow wiki | Factory