Skip to content

Commit

Permalink
Hide Method's ctor and init() (#336)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dbort authored and facebook-github-bot committed Sep 14, 2023
1 parent 73f699a commit 4f3e5e6
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions runtime/executor/method.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,6 @@ using InstructionArgs = Span<EValue*>;
*/
class Method final {
public:
Method(
const Program* program,
MemoryManager* memory_manager,
EventTracer* event_tracer)
: step_state_(),
program_(program),
memory_manager_(memory_manager),
serialization_plan_(nullptr),
event_tracer_(event_tracer),
n_value_(0),
values_(nullptr),
n_delegate_(0),
delegates_(nullptr),
n_chains_(0),
chains_(nullptr),
init_state_(InitializationState::Uninitialized),
pre_allocated_input_(false),
pre_allocated_output_(false) {}

/**
* Move ctor. Takes ownership of resources previously owned by `rhs`,
* and leaves `rhs` in an uninitialized state.
Expand Down Expand Up @@ -106,13 +87,6 @@ class Method final {
rhs.pre_allocated_output_ = false;
}

/**
* Initialize the method from its serialized representation.
*
* @returns Error::Ok on success, non-Ok on failure.
*/
__ET_NODISCARD Error init(executorch_flatbuffer::ExecutionPlan* s_plan);

/**
* Sets a specific method input to the provided value.
*
Expand Down Expand Up @@ -243,6 +217,8 @@ class Method final {

// Let Program call load().
friend class Program;
// Let Executor call the ctor and init().
friend class Executor;

enum class InitializationState : uint8_t {
Uninitialized,
Expand All @@ -256,13 +232,39 @@ class Method final {
size_t instr_idx;
};

Method(
const Program* program,
MemoryManager* memory_manager,
EventTracer* event_tracer)
: step_state_(),
program_(program),
memory_manager_(memory_manager),
serialization_plan_(nullptr),
event_tracer_(event_tracer),
n_value_(0),
values_(nullptr),
n_delegate_(0),
delegates_(nullptr),
n_chains_(0),
chains_(nullptr),
init_state_(InitializationState::Uninitialized),
pre_allocated_input_(false),
pre_allocated_output_(false) {}

/// Static factory used by Program.
__ET_NODISCARD static Result<Method> load(
executorch_flatbuffer::ExecutionPlan* s_plan,
const Program* program,
MemoryManager* memory_manager,
EventTracer* event_tracer);

/**
* Initialize the method from its serialized representation.
*
* @returns Error::Ok on success, non-Ok on failure.
*/
__ET_NODISCARD Error init(executorch_flatbuffer::ExecutionPlan* s_plan);

/// Returns true if the Method was successfully initialized.
inline bool initialized() const {
return init_state_ == InitializationState::Initialized;
Expand Down

0 comments on commit 4f3e5e6

Please sign in to comment.