Welcome to TensorFlow

Your guide to understanding the codebase.

Learning Path

16 units • 5 levels

Orchestration & APIs

  • Pipelines, workflows, public interfaces (2 units)
  • TensorFlow Core APIs and Bindings (8 units)
  • Op Registration and Kernel Implementation (3 units)

Core Logic & Data

  • Business rules, schemas, models (3 units)
  • Execution Modes and Function Abstraction (10 units)
  • TensorFlow Lite Architecture (5 units)
  • Automatic Differentiation and Gradients (4 units)

Interaction & Integration

  • UI components, external connectors (3 units)
  • MLIR and Compiler Infrastructure (8 units)
  • Pluggable Infrastructure and Extensions (3 units)
  • Graph Optimization and Compilation (10 units)

Cross-Cutting Concerns

  • Auth, logging, config, testing (3 units)
  • Distributed Training and Execution (12 units)

Production Infrastructure

  • Deployment
  • Quantization and Model Optimization (3 units)
  • Edge Cases & Resilience (2 units)

Additional Data Model Patterns

  • Additional Error Handling Patterns (4 units)

Test Your Knowledge

Test your deep understanding of the codebase.

Question Tiers

  1. Purpose & Problem (8)
  2. Architecture (10)
  3. Design & Patterns (8)
  4. Implementation (2-3 hours)

Your Challenge

Implement a custom TensorFlow operation that performs element-wise string reversal on string tensors, including both the CPU kernel implementation and proper gradient registration. Your op should integrate with TensorFlow's op registration system, handle different input shapes correctly, and be callable from both Python and C++ APIs. This will require understanding TensorFlow's kernel dispatch mechanism, memory management, and the op registration infrastructure.

Starting Points

  • tensorflow/c/c_api.h:1-80 - Examine the C API structure for tensor operations and status handling
  • tensorflow/c/c_api.cc:1-30 - Study how TensorFlow's C API implements core tensor operations
  • tensorflow/core/ops/ - This directory contains op definitions - you'll create a new op definition file here following the REGISTER_OP pattern
  • tensorflow/core/kernels/ - Add your kernel implementation here with CPU (and optionally GPU) device support
  • tensorflow/core/ops/string_ops.cc - Reference existing string operations to understand shape inference and attribute handling
  • tensorflow/core/kernels/string_strip_op.cc - Study this for patterns on processing string tensors and memory management
  • tensorflow/python/ops/string_ops.py - You'll need to add Python bindings here to make your op accessible from Python

Success Criteria

  • Op is registered and appears in tf.raw_ops with proper documentation
  • CPU kernel correctly reverses strings element-wise for tensors of any shape
  • Python wrapper function is accessible as tf.strings.reverse() or similar
  • Handles edge cases: empty strings, unicode/UTF-8 characters, scalar tensors
  • Works in both eager mode and within tf.function compiled graphs
  • Gradient is properly registered (even if it returns None)
  • Unit tests pass demonstrating correctness on various input shapes and types
  • Bazel build completes successfully: bazel build //tensorflow/core/kernels:your_op

Hints

  1. Understanding Op Registration
  2. Kernel Implementation Pattern
  3. Shape Inference Function
  4. Gradient Registration
  5. Testing Your Op

Prerequisites: C++ basics and memory management, TensorFlow tensor concepts, Op registration and kernel dispatch, Bazel build system fundamentals.