tensorflow/tensorflow
Tooling
The build system, code generators, and supporting scripts.
Bazel
Bazel is the only blessed build system. Important pieces:
WORKSPACEandMODULE.bazel— repo-level dependencies. The transition fromWORKSPACEtobzlmodis 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..bazelignoreand.bazelversion.tensorflow/tensorflow.bzl— the project's central macro library (~130 KB). It definestf_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 wrappers —
tensorflow/python/ops/gen_*.py. Generated by Bazel ruletf_gen_op_wrapper_py(intensorflow.bzl) fromOpDefregistrations. The generator binary lives intensorflow/python/framework/python_op_gen_main.cc. - C++ ops —
tensorflow/cc/ops/*.h,ccproduced bytf_gen_op_wrappers_ccfor each op family (tensorflow/core/ops/). Resulting headers exposeMatMul(...),Add(...), etc., as a builder API for C++. - Python API stubs —
tensorflow/api_template.__init__.pyandtensorflow/api_template_v1.__init__.pyare templates. Bazel rulegen_api_init_files_py(tensorflow/tools/api/) walks@tf_export(...)decorators and produces the fulltensorflow/_api/v2/tree at build time. - Protobufs —
tensorflow/core/protobuf/*.proto,tensorflow/core/framework/*.proto. Generated*_pb2.pyfiles for Python; C++ generated headers inbazel-bin/. - FlatBuffers —
tensorflow/lite/schema/schema.fbs,tensorflow/lite/schema/conversion_metadata.fbs. Generated*.hfor C++ and*.pyfor Python.
Don't edit any gen_*.py or *_pb2.py by hand.
Lint
- C++:
clang-format(config.clang-format). - Python:
pylint(configtensorflow/tools/ci_build/pylintrc, root symlink.pylintrc). - Bazel:
buildifier. - Markdown: light style only; some directories run
mdformatin CI.
Doc generation
- API docs are generated by
tensorflow/tools/docs/. - The generator emits Markdown the
tensorflow/docsrepo (separate) renders. tensorflow/lite/g3doc/andtensorflow/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. |
Related
- development-workflow — how CI gates changes.
- reference/configuration — the env vars surfaced by
./configure.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.