@@ -47,25 +47,6 @@ using InstructionArgs = Span<EValue*>;
47
47
*/
48
48
class Method final {
49
49
public:
50
- Method (
51
- const Program* program,
52
- MemoryManager* memory_manager,
53
- EventTracer* event_tracer)
54
- : step_state_(),
55
- program_ (program),
56
- memory_manager_(memory_manager),
57
- serialization_plan_(nullptr ),
58
- event_tracer_(event_tracer),
59
- n_value_(0 ),
60
- values_(nullptr ),
61
- n_delegate_(0 ),
62
- delegates_(nullptr ),
63
- n_chains_(0 ),
64
- chains_(nullptr ),
65
- init_state_(InitializationState::Uninitialized),
66
- pre_allocated_input_(false ),
67
- pre_allocated_output_(false ) {}
68
-
69
50
/* *
70
51
* Move ctor. Takes ownership of resources previously owned by `rhs`,
71
52
* and leaves `rhs` in an uninitialized state.
@@ -106,13 +87,6 @@ class Method final {
106
87
rhs.pre_allocated_output_ = false ;
107
88
}
108
89
109
- /* *
110
- * Initialize the method from its serialized representation.
111
- *
112
- * @returns Error::Ok on success, non-Ok on failure.
113
- */
114
- __ET_NODISCARD Error init (executorch_flatbuffer::ExecutionPlan* s_plan);
115
-
116
90
/* *
117
91
* Sets a specific method input to the provided value.
118
92
*
@@ -243,6 +217,8 @@ class Method final {
243
217
244
218
// Let Program call load().
245
219
friend class Program ;
220
+ // Let Executor call the ctor and init().
221
+ friend class Executor ;
246
222
247
223
enum class InitializationState : uint8_t {
248
224
Uninitialized,
@@ -256,13 +232,39 @@ class Method final {
256
232
size_t instr_idx;
257
233
};
258
234
235
+ Method (
236
+ const Program* program,
237
+ MemoryManager* memory_manager,
238
+ EventTracer* event_tracer)
239
+ : step_state_(),
240
+ program_(program),
241
+ memory_manager_(memory_manager),
242
+ serialization_plan_(nullptr ),
243
+ event_tracer_(event_tracer),
244
+ n_value_(0 ),
245
+ values_(nullptr ),
246
+ n_delegate_(0 ),
247
+ delegates_(nullptr ),
248
+ n_chains_(0 ),
249
+ chains_(nullptr ),
250
+ init_state_(InitializationState::Uninitialized),
251
+ pre_allocated_input_(false ),
252
+ pre_allocated_output_(false ) {}
253
+
259
254
// / Static factory used by Program.
260
255
__ET_NODISCARD static Result<Method> load (
261
256
executorch_flatbuffer::ExecutionPlan* s_plan,
262
257
const Program* program,
263
258
MemoryManager* memory_manager,
264
259
EventTracer* event_tracer);
265
260
261
+ /* *
262
+ * Initialize the method from its serialized representation.
263
+ *
264
+ * @returns Error::Ok on success, non-Ok on failure.
265
+ */
266
+ __ET_NODISCARD Error init (executorch_flatbuffer::ExecutionPlan* s_plan);
267
+
266
268
// / Returns true if the Method was successfully initialized.
267
269
inline bool initialized () const {
268
270
return init_state_ == InitializationState::Initialized;
0 commit comments