Skip to content

Commit b66d62a

Browse files
authored
Add ET_EXPERIMENTAL
Differential Revision: D61368408 Pull Request resolved: #4802
1 parent db7a378 commit b66d62a

File tree

4 files changed

+41
-24
lines changed

4 files changed

+41
-24
lines changed

docs/source/api-life-cycle.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,21 @@ communicate state to developers.
9191
<td>
9292

9393
Use the
94-
<a href="https://typing-extensions.readthedocs.io/en/latest/#typing_extensions.deprecated">typing_extensions.deprecated</a>
95-
decorator
94+
<a href="https://github.com/pytorch/executorch/blob/main/exir/_warnings.py">executorch.exir._warnings.deprecated</a>
95+
decorator.
9696

9797
<p>
98-
Use ExecuTorch's native experimental decorator (TODO not yet implemented)
98+
Use the
99+
<a href="https://github.com/pytorch/executorch/blob/main/exir/_warnings.py">executorch.exir._warnings.experimental</a>
100+
decorator.
99101

100102
</td>
101103
<td>
102104

103105
Use <code>.. warning::</code> in the docstrings of deprecated and experimental
104106
APIs. See
105107
<a href="https://github.com/pytorch/pytorch/blob/cd8bbdc71a0258292381a7d54c8b353988d02ff4/torch/nn/utils/stateless.py#L170">example
106-
usage</a>
108+
usage</a>.
107109

108110
</ul>
109111
</td>
@@ -113,35 +115,35 @@ usage</a>
113115
</td>
114116
<td>
115117

116-
Use <code>ET_DEPRECATED</code> macros. See <a href="https://github.com/pytorch/executorch/blob/8e0f856ee269b319ac4195509cf31e3f548aa0e8/runtime/executor/program.h#L81">example usage</a>
118+
Use the <code>ET_DEPRECATED</code> annotation macro. See <a href="https://github.com/pytorch/executorch/blob/8e0f856ee269b319ac4195509cf31e3f548aa0e8/runtime/executor/program.h#L81">example usage</a>.
117119

118120
<p>
119121
<p>
120-
Use <code>ET_EXPERIMENTAL</code> macros (TODO not yet implemented)
122+
Use the <code>ET_EXPERIMENTAL</code> annotation macro.
121123
</ul>
122124
</td>
123125
<td>
124126

125127
Start Doxygen comments with <code>DEPRECATED:</code> See
126128
<a href="https://github.com/pytorch/executorch/blob/9d859653ae916d0a72f6b2b5c5925bed38832140/runtime/executor/program.h#L139">example
127-
usage</a>
129+
usage</a>.
128130

129131
<p>
130132
<p>
131-
Start Doxygen comments with <code>EXPERIMENTAL:</code>
133+
Start Doxygen comments with <code>EXPERIMENTAL:</code>.
132134
</td>
133135
</tr>
134136
<tr>
135137
<td>Java
136138
</td>
137139
<td>
138140

139-
Use <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Deprecated.html">java.lang.Deprecated</a>
141+
Use <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Deprecated.html">java.lang.Deprecated</a>.
140142

141143
<p>
142144
<p>
143145

144-
Use <a href="https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:docs/api_guidelines/annotations.md">androidx.annotation.RequiresOptIn</a>
146+
Use <a href="https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:docs/api_guidelines/annotations.md">androidx.annotation.RequiresOptIn</a>.
145147

146148
</td>
147149
<td>
@@ -164,7 +166,7 @@ Use <a href="https://cs.android.com/androidx/platform/frameworks/support/+/andro
164166
<code>__attribute__((deprecated("Use newMethod instead")));</code>
165167
<p>
166168
<p>
167-
<code>__attribute__((experimental("Use newMethod instead")));</code> (TODO not yet implemented)
169+
<code>__attribute__((deprecated("This API is experimental and may change without notice.")));</code>
168170
</td>
169171
<td>
170172
<p>

runtime/executor/method.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ Error Method::execute_instruction() {
11761176
return err;
11771177
}
11781178

1179-
Error Method::experimental_reset_execution() {
1179+
Error Method::reset_execution() {
11801180
ET_CHECK_OR_RETURN_ERROR(
11811181
step_state_.chain_idx == n_chains_,
11821182
InvalidState,
@@ -1185,6 +1185,10 @@ Error Method::experimental_reset_execution() {
11851185
return Error::Ok;
11861186
}
11871187

1188+
Error Method::experimental_reset_execution() {
1189+
return reset_execution(); // @lint-ignore CLANGTIDY facebook-hte-Deprecated
1190+
}
1191+
11881192
// Log all the outputs of this method to the event tracer.
11891193
void Method::log_outputs() {
11901194
#ifdef ET_EVENT_TRACER_ENABLED
@@ -1199,7 +1203,7 @@ void Method::log_outputs() {
11991203
#endif
12001204
}
12011205

1202-
Error Method::experimental_step() {
1206+
Error Method::step() {
12031207
EXECUTORCH_PROFILE_INSTRUCTION_SCOPE(
12041208
static_cast<int32_t>(step_state_.chain_idx),
12051209
static_cast<uint32_t>(step_state_.instr_idx));
@@ -1245,6 +1249,10 @@ Error Method::experimental_step() {
12451249
return Error::Ok;
12461250
}
12471251

1252+
Error Method::experimental_step() {
1253+
return step();
1254+
}
1255+
12481256
Error Method::execute() {
12491257
internal::event_tracer_create_event_block(event_tracer_, "Execute");
12501258
internal::EventTracerProfileScope event_tracer_profile_scope =
@@ -1289,7 +1297,7 @@ Error Method::execute() {
12891297

12901298
// TODO(jakeszwe, dbort): Decide on calling execute back to back without
12911299
// going through the reset api first.
1292-
return experimental_reset_execution();
1300+
return reset_execution(); // @lint-ignore CLANGTIDY facebook-hte-Deprecated
12931301
}
12941302

12951303
MethodMeta Method::method_meta() const {

runtime/executor/method.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,35 +181,37 @@ class Method final {
181181
* Execute the method.
182182
*
183183
* NOTE: Will fail if the method has been partially executed using the
184-
* `experimental_step()` api.
184+
* `step()` api.
185185
*
186186
* @returns Error::Ok on success, non-Ok on failure.
187187
*/
188188
ET_NODISCARD Error execute();
189189

190190
/**
191-
* Advances/executes a single instruction in the method.
192-
*
193-
* NOTE: Prototype API; subject to change.
191+
* EXPERIMENTAL: Advances/executes a single instruction in the method.
194192
*
195193
* @retval Error::Ok step succeeded
196194
* @retval non-Ok step failed
197195
* @retval Error::EndOfMethod method finished executing successfully
198196
*/
199-
ET_NODISCARD Error experimental_step();
197+
ET_EXPERIMENTAL ET_NODISCARD Error step();
198+
199+
/// DEPRECATED: Use `step()` instead.
200+
ET_DEPRECATED ET_NODISCARD Error experimental_step();
200201

201202
/**
202-
* Resets execution state to the start of the Method. For use with the
203-
* `experimental_step()` API.
204-
*
205-
* NOTE: Prototype API; subject to change.
203+
* EXPERIMENTAL: Resets execution state to the start of the Method. For use
204+
* with the `step()` API.
206205
*
207206
* @retval Error:Ok on success
208207
* @retval Error::InvalidState if called before step-based execution reached
209208
* the end of the Method. This means it is not possible to recover a
210209
* Method that failed mid-execution.
211210
*/
212-
ET_NODISCARD Error experimental_reset_execution();
211+
ET_EXPERIMENTAL ET_NODISCARD Error reset_execution();
212+
213+
/// DEPRECATED: Use `reset_execution()` instead.
214+
ET_DEPRECATED ET_NODISCARD Error experimental_reset_execution();
213215

214216
/**
215217
* Returns the MethodMeta that corresponds to the calling Method.

runtime/platform/compiler.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,18 @@
6262
#if (__cplusplus) >= 201703L
6363

6464
#define ET_DEPRECATED [[deprecated]]
65+
#define ET_EXPERIMENTAL \
66+
[[deprecated("This API is experimental and may change without notice.")]]
6567
#define ET_FALLTHROUGH [[fallthrough]]
6668
#define ET_NODISCARD [[nodiscard]]
6769
#define ET_UNUSED [[maybe_unused]]
6870

6971
#else
7072

7173
#define ET_DEPRECATED __attribute__((deprecated))
74+
#define ET_EXPERIMENTAL \
75+
__attribute__(( \
76+
deprecated("This API is experimental and may change without notice.")))
7277
#define ET_FALLTHROUGH __attribute__((fallthrough))
7378
#define ET_NODISCARD __attribute__((warn_unused_result))
7479
#define ET_UNUSED __attribute__((unused))

0 commit comments

Comments
 (0)