AGENTS.md
third_party/xla/xla/AGENTS.mdAGENTS.md
Quality
60/100
Scores the file, not the repository.Length
503 words
3 headings · 2 code blocksRepository
197k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# AI Assistant Guidelines for OpenXLA Development23This document provides guidelines for AI code assistants when generating,4suggesting, or modifying code within the5`third_party/tensorflow/compiler/xla` (OpenXLA) codebase.67## General Context89* **Impact:** OpenXLA is a core compiler for machine learning acceleration. Changes here affect the open-source community and various hardware backends.10* **Code Quality:** Adhere to [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) and OpenXLA-specific conventions.11* **Portability:** This code is open-sourced and runs on a number of host platforms (e.g. Linux, Windows, etc.)1213## Coding Guidelines for AI Assistance14151. **Error Handling (`absl::Status`, `absl::StatusOr`)**:16 * **Always** use `absl::Status` or `absl::StatusOr<T>` for functions that can encounter recoverable errors.17 * **Macros**:18 * Use header `tsl/platform/status_macros.h`.19 * Use `RETURN_IF_ERROR` for error propagation.20 * Use `ASSIGN_OR_RETURN` for `StatusOr` assignments.21 * **Safely access `StatusOr<T>` values**: Check `.ok()` before accessing.22232. **Assertions & Invariant Checks (`TF_RET_CHECK`)**:24 * **Avoid `DCHECK` / `LOG(DFATAL)`** for checking returnable errors.25 * **Prefer `TF_RET_CHECK`**:26 * Located in `xla/status_macros.h`.27 * Use strict internal invariant checks inside functions returning `absl::Status` / `StatusOr`.28 * Example:29```cpp30 #include "xla/status_macros.h"3132 absl::Status Process(const Thing* t) {33 TF_RET_CHECK(t != nullptr) << "Thing cannot be null";34 // ...35 return absl::OkStatus();36 }37```383. **Decision making**:39 * **Avoid `bool`** for returning a decision to do or not to do something.40 * **Prefer `Decision`**:41 * Located in `third_party/tensorflow/compiler/xla/service/decision.h`42 * Example:43```cpp44 #include "third_party/tensorflow/compiler/xla/service/decision.h"4546 using AutotunerDecision = Decision;4748 AutotunerDecision ShouldAutotuneCublasCall(HloInstruction* instr) {49 // ...50 return AutotunerDecision::Forbid("Cublas autotuning was explicitly disabled");51 }5253 voud AutotuneCublas(const AutotunerDecision& decision) {54 if (decision.IsForbidden()) {55 return;56 }57 ...58```59604. **Performance Sensitivity**:61 * OpenXLA is a compiler; patterns should be efficient.62 * Avoid unnecessary string copies or expensive allocations in hot paths (e.g., HLO passes).63645. **Testing**:65 * Write unit tests using `EXPECT_EQ`, `EXPECT_TRUE`, etc.66 * Use macros in `tsl/platform/status_matchers.h` instead of their TF_*67 counterparts. For example:68 * Use `ASSERT_OK_AND_ASSIGN`, `ASSERT_OK`, and `EXPECT_OK`.69 * DO NOT USE `TF_ASSERT_OK_AND_ASSIGN`, `TF_ASSERT_OK`, and70 `TF_EXPECT_OK`.71 * When you refactor code that uses the TF_* macros., replace them, but72 do not touch unrelated code.73 * Put tests into an anonymous namespace74 * Use `HloPjRtInterpreterReferenceMixin<HloPjRtTestBase>` or75 `HloHardwareIndependentTestBase` for compiler pass tests locally where76 possible.77 * Ensure tests are deterministic and do not flake.78796. **BUILD targets**:80 * When defining BUILD targets prefer these XLA specific rules:81 * Instead of `proto_library` use `tf_proto_library`. There is no need82 to define language specific targets with `tf_proto_library`.83 * Instead of `cc_test` use `xla_cc_test`.84857. **Explicit Typing**:86 * **Avoid `auto`** in public headers or complex logic chains.87888. **Compiler Phases & Invariants**:89 * **Phase Ordering**: Understand where your pass or change sits in the pipeline (e.g., Optimizations, Layout Assignment, Fusion).90 * **Invariants**: Respect the invariants of the current phase.91 * *Example*: Do not generate `kCustomCall` instructions before the relevant expansion pass if they are not supported by the HLO verifier at that stage.92 * *Example*: Do not rely on layout information before Layout Assignment.93949. **Namespaces**:95 * Prefer xla::gpu over nested namespaces.969710. **MLIR Operation Creation**:98 * **Always** use the static `OpTy::create(rewriter, ...)` method when creating MLIR operations.99 * **Avoid** using `rewriter.create<OpTy>(...)`. This syntax is deprecated.100
Also in tensorflow/tensorflow
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| tensorflow/tensorflowthird_party/xla/xla/GEMINI.md · 197k | GEMINI.md | no sections | 4/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| vllm-project/vllmAGENTS.md · 88k | AGENTS.md | setuptestlint-formatstyle+5 | 100/100 | 3 days ago | |
| unoplat/unoplat-code-confluenceunoplat-code-confluence-frontend/AGENTS.md · 95 | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| OnlyTerp/prompt-cache-skillsAGENTS.md · 112 | AGENTS.md | setupbuildtestlint-format+5 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| netdata/netdatasrc/go/plugin/ibm.d/AGENTS.md · 80k | AGENTS.md | buildtestlint-formatarch+3 | 99/100 | 3 days ago | |
| react/react-nativepackages/react-native-compatibility-check/AGENTS.md · 126k | AGENTS.md | testlint-formatstylearch+4 | 99/100 | 3 days ago | |
| unoplat/unoplat-code-confluenceunoplat-code-confluence-query-engine/AGENTS.md · 95 | AGENTS.md | setupbuildtestlint-format+5 | 98/100 | 2 days ago |
