Skip to content

Commit 4f3e5e6

Browse files
dbortfacebook-github-bot
authored andcommitted
Hide Method's ctor and init() (#336)
Summary: Pull Request resolved: #336 These were never meant for public use. Hide them to clean up the public API. Reviewed By: mergennachin Differential Revision: D47743955 fbshipit-source-id: 3ddc97a2665662fec92559dd69bbcca5f3750203
1 parent 73f699a commit 4f3e5e6

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

runtime/executor/method.h

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,6 @@ using InstructionArgs = Span<EValue*>;
4747
*/
4848
class Method final {
4949
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-
6950
/**
7051
* Move ctor. Takes ownership of resources previously owned by `rhs`,
7152
* and leaves `rhs` in an uninitialized state.
@@ -106,13 +87,6 @@ class Method final {
10687
rhs.pre_allocated_output_ = false;
10788
}
10889

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-
11690
/**
11791
* Sets a specific method input to the provided value.
11892
*
@@ -243,6 +217,8 @@ class Method final {
243217

244218
// Let Program call load().
245219
friend class Program;
220+
// Let Executor call the ctor and init().
221+
friend class Executor;
246222

247223
enum class InitializationState : uint8_t {
248224
Uninitialized,
@@ -256,13 +232,39 @@ class Method final {
256232
size_t instr_idx;
257233
};
258234

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+
259254
/// Static factory used by Program.
260255
__ET_NODISCARD static Result<Method> load(
261256
executorch_flatbuffer::ExecutionPlan* s_plan,
262257
const Program* program,
263258
MemoryManager* memory_manager,
264259
EventTracer* event_tracer);
265260

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+
266268
/// Returns true if the Method was successfully initialized.
267269
inline bool initialized() const {
268270
return init_state_ == InitializationState::Initialized;

0 commit comments

Comments
 (0)