You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CODING_STANDARDS/FUNCTIONAL_APIS.md
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ This document is structured in two main sections:
53
53
54
54
| Rule ID | Summary | Apply When |
55
55
|---------|---------|------------|
56
-
|[`FNC-000`](#fnc-000-functionals-must-use-functionspec)| Functionals must use FunctionSpec | Creating new functional APIs |
56
+
|[`FNC-000`](#fnc-000-functionals-must-use-functionspec)| Functionals must use FunctionSpec unless they are lightweight tensor helpers | Creating new functional APIs |
57
57
|[`FNC-001`](#fnc-001-functional-location-and-public-api)| Functional location and public API | Organizing or exporting functionals |
58
58
|[`FNC-002`](#fnc-002-file-layout-for-functionals)| File layout for functionals | Adding or refactoring functional files |
59
59
|[`FNC-003`](#fnc-003-registration-and-dispatch-rules)| Registration and dispatch rules | Registering implementations |
@@ -71,15 +71,30 @@ This document is structured in two main sections:
71
71
72
72
**Description:**
73
73
74
-
All functionals must be implemented with `FunctionSpec`, even if only a single
75
-
implementation exists. This ensures the operation participates in validation
76
-
and benchmarking through input generators and `compare_forward` (and
74
+
All functionals with backend dispatch, optional accelerated implementations, or
75
+
meaningful benchmark coverage must be implemented with `FunctionSpec`, even if
76
+
only a single implementation exists. This ensures the operation participates in
77
+
validation and benchmarking through input generators and `compare_forward` (and
77
78
`compare_backward` where needed).
78
79
80
+
Small pure-PyTorch tensor helpers may remain plain functions when all of the
81
+
following are true:
82
+
83
+
- The implementation is a thin composition of PyTorch tensor operations.
84
+
- There is no optional backend, custom kernel, or dispatch-selection behavior.
85
+
- Benchmarking the helper independently would not provide actionable
86
+
performance data.
87
+
- The function has focused tests or coverage through its owning feature area.
88
+
89
+
When a helper later grows an alternate backend, optional dependency, or
90
+
performance-sensitive implementation, convert it to `FunctionSpec`.
91
+
79
92
**Rationale:**
80
93
81
94
`FunctionSpec` provides a consistent structure for backend registration,
82
-
selection, benchmarking and verification across the codebase.
95
+
selection, benchmarking and verification across the codebase. The lightweight
96
+
helper exception avoids adding ceremony to simple tensor algebra that has no
0 commit comments