Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions runtime/executor/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,10 @@ Error Method::reset_execution() {
InvalidState,
"Cannot reset until EndOfMethod has been reached.");
step_state_ = StepState{0, 0};
const auto n_input = inputs_size();
for (size_t i = 0; i < n_input; ++i) {
input_set_[i] = false;
}
return Error::Ok;
}

Expand Down
18 changes: 18 additions & 0 deletions runtime/executor/test/kernel_integration_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ TEST_F(KernelIntegrationTest, KernelHookIsCalled) {
EXPECT_EQ(err, Error::Ok);
EXPECT_EQ(control_->call_count, 1);

// Set up inputs again.
auto inputs_cleanup = executorch::extension::prepare_input_tensors(*method_);
ASSERT_EQ(inputs_cleanup.error(), Error::Ok);
auto input_err = method_->set_input(executorch::runtime::EValue(1.0), 2);
ASSERT_EQ(input_err, Error::Ok);

// Calling it again bumps the count.
err = method_->execute();
EXPECT_EQ(err, Error::Ok);
Expand Down Expand Up @@ -336,6 +342,12 @@ TEST_F(KernelIntegrationTest, DefaultPlatformMemoryAllocator) {
EXPECT_EQ(control_->call_count, 1);
EXPECT_EQ(control_->total_allocated_size, 4);

// Set up inputs again.
auto inputs_cleanup = executorch::extension::prepare_input_tensors(*method_);
ASSERT_EQ(inputs_cleanup.error(), Error::Ok);
auto input_err = method_->set_input(executorch::runtime::EValue(1.0), 2);
ASSERT_EQ(input_err, Error::Ok);

control_->temp_memory_size = 8;
// This is not a simulation. This actually allocates memory, using the
// default platform memory allocator.
Expand Down Expand Up @@ -371,6 +383,12 @@ TEST_F(KernelTempMemoryAllocatorIntegrationTest, UsingTempMemoryAllocator) {
EXPECT_EQ(temp_allocator_->number_of_resets, 1);
EXPECT_EQ(temp_allocator_->currently_allocated_size, 0);

// Set up inputs again.
auto inputs_cleanup = executorch::extension::prepare_input_tensors(*method_);
ASSERT_EQ(inputs_cleanup.error(), Error::Ok);
auto input_err = method_->set_input(executorch::runtime::EValue(1.0), 2);
ASSERT_EQ(input_err, Error::Ok);

control_->temp_memory_size = 8;
err = method_->execute();
EXPECT_EQ(err, Error::Ok);
Expand Down
6 changes: 6 additions & 0 deletions runtime/executor/test/method_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ TEST_F(MethodTest, MoveTest) {
Error err = method->execute();
ASSERT_EQ(err, Error::Ok);

// Set dummy inputs again.
auto input_cleanup2 = prepare_input_tensors(*method);
ASSERT_EQ(input_cleanup2.error(), Error::Ok);
input_err = method->set_input(executorch::runtime::EValue(1.0), 2);
ASSERT_EQ(input_err, Error::Ok);

// Move into a new Method.
Method new_method(std::move(method.get()));

Expand Down
Loading