You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ET is updating the pybinding functions by migrating from pybinding.module into extension.module. BundledProgram has become a blocker for migration because:
BundledProgram APIs take method module as input
Extension.module does not expose method class to outside
This document focuses on solving the issue while having long-term benefits.
Targets:
We want to make some updates to replace pybinding.module with extension.module in pybinding functions and continue with the following requirements:
Supporting the current pybinding functionality of bundled program without BC issue
Supporting current Bundled Program users without BC issue
Don’t expose method class from extension.module
Proposals:
Create a new class called BundledModule, which extends the current Module class, specific for bundled program stuff. This way we wrap all method-related under BundledModule and not expose them:
classBundledModule : publicModule {
// create BundledModule from given bundled program fileexplicitBundledModule(const std::string& bundled_program_path);
// get given method with input_index-th bundled input.
ET_NODISCARD inline runtime::Result<std::vector<runtime::Evalue>> get_bundled_input(const std::string& method_name, const input_index);
// compare the output of given method with output_index-th bundled expected output. Inside it invokes executorch::bundled_program::verify_method_outputs
ET_NODISCARD inline runtime::Result<bool> verify_output_with_bundled(const std::string& method_name, constsize_t bundled_output_index, std::vector<runtime::Evalue> method_output, other_comparison_configs);
// extract Module class from BundledModule
ET_NODISCARD inline runtime::Result<Module> extract_module();
}
Furthermore, in this scenario, we need to touch the method variable in the BundledModule, but the method variable is a private member of the Module class, so we should introduce an extra get function in Module’s protected scope to retrieve method module from method name while not exposing it to outside:
classModule {
// Everything else keeps sameprotected:// return method based on its name
ET_NODISCARD inline runtime::Result<Method> get_method(const std::string& method_name);
}
And need to introduce a utility function to the bundled program codebase:
// under bundled_program.bundled_program.h/** * Load testset_idx-th bundled input of method_name into given data_ptr */
ET_NODISCARD ::executorch::runtime::Error get_bundled_input(
SerializedBundledProgram* bundled_program_ptr,
char* method_name,
size_t testset_idx,
void* data_ptr,
size_t data_length);
In this way, we can make our final pybinding neat and concise:
py::list verify_result_with_bundled_expected_output(
PyBundledModule& m, // here we can make PyBundledModule as a simple wrapper of BundledModuleconst std::string method_name,
size_t testset_idx,
double rtol = 1e-5,
double atol = 1e-8) {
input = m.get_bundled_input(method_name, testset_idx);
output = m.execute(method_name, input);
m.verify_output_with_bundled(method_name, testset_idx, output, rtol, atol);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
ET is updating the pybinding functions by migrating from
pybinding.module
intoextension.module
. BundledProgram has become a blocker for migration because:BundledProgram
APIs take method module as inputExtension.module
does not expose method class to outsideThis document focuses on solving the issue while having long-term benefits.
Targets:
We want to make some updates to replace
pybinding.module
withextension.module
in pybinding functions and continue with the following requirements:extension.module
Proposals:
Create a new class called BundledModule, which extends the current Module class, specific for bundled program stuff. This way we wrap all method-related under
BundledModule
and not expose them:Furthermore, in this scenario, we need to touch the method variable in the BundledModule, but the method variable is a private member of the Module class, so we should introduce an extra get function in Module’s protected scope to retrieve method module from method name while not exposing it to outside:
And need to introduce a utility function to the bundled program codebase:
In this way, we can make our final pybinding neat and concise:
@cccclai @tarun292 @byjlw
Beta Was this translation helpful? Give feedback.
All reactions