@@ -13,9 +13,9 @@ using ::executorch::runtime::Error;
1313BaseModel::BaseModel (const std::string &modelSource,
1414 std::shared_ptr<react::CallInvoker> callInvoker)
1515 : callInvoker(callInvoker),
16- module (std::make_unique<Module>(
16+ module_ (std::make_unique<Module>(
1717 modelSource, Module::LoadMode::MmapUseMlockIgnoreErrors)) {
18- Error loadError = module ->load ();
18+ Error loadError = module_ ->load ();
1919 if (loadError != Error::Ok) {
2020 throw std::runtime_error (" Failed to load model: Error " +
2121 std::to_string (static_cast <int >(loadError)));
@@ -30,11 +30,11 @@ BaseModel::BaseModel(const std::string &modelSource,
3030
3131std::vector<int32_t > BaseModel::getInputShape (std::string method_name,
3232 int index) {
33- if (!module ) {
33+ if (!module_ ) {
3434 throw std::runtime_error (" Model not loaded: Cannot get input shape" );
3535 }
3636
37- auto method_meta = module ->method_meta (method_name);
37+ auto method_meta = module_ ->method_meta (method_name);
3838 if (!method_meta.ok ()) {
3939 throw std::runtime_error (
4040 " Failed to get metadata for method '" + method_name + " ': Error " +
@@ -56,11 +56,11 @@ std::vector<int32_t> BaseModel::getInputShape(std::string method_name,
5656
5757std::vector<std::vector<int32_t >>
5858BaseModel::getAllInputShapes (std::string methodName) {
59- if (!module ) {
59+ if (!module_ ) {
6060 throw std::runtime_error (" Model not loaded: Cannot get all input shapes" );
6161 }
6262
63- auto method_meta = module ->method_meta (methodName);
63+ auto method_meta = module_ ->method_meta (methodName);
6464 if (!method_meta.ok ()) {
6565 throw std::runtime_error (
6666 " Failed to get metadata for method '" + methodName + " ': Error " +
@@ -85,7 +85,7 @@ BaseModel::getAllInputShapes(std::string methodName) {
8585
8686std::vector<JSTensorViewOut>
8787BaseModel::forwardJS (const std::vector<JSTensorViewIn> tensorViewVec) {
88- if (!module ) {
88+ if (!module_ ) {
8989 throw std::runtime_error (" Model not loaded: Cannot perform forward pass" );
9090 }
9191 std::vector<executorch::runtime::EValue> evalues;
@@ -107,7 +107,7 @@ BaseModel::forwardJS(const std::vector<JSTensorViewIn> tensorViewVec) {
107107 // which implicitly converts to EValue
108108 }
109109
110- auto result = module ->forward (evalues);
110+ auto result = module_ ->forward (evalues);
111111 if (!result.ok ()) {
112112 throw std::runtime_error (" Forward pass failed: Error " +
113113 std::to_string (static_cast <int >(result.error ())));
@@ -132,23 +132,23 @@ BaseModel::forwardJS(const std::vector<JSTensorViewIn> tensorViewVec) {
132132}
133133
134134Result<std::vector<EValue>> BaseModel::forward (const EValue &input_evalue) {
135- if (!module ) {
135+ if (!module_ ) {
136136 throw std::runtime_error (" Model not loaded: Cannot perform forward pass" );
137137 }
138- return module ->forward (input_evalue);
138+ return module_ ->forward (input_evalue);
139139}
140140
141141Result<std::vector<EValue>>
142142BaseModel::forward (const std::vector<EValue> &input_evalues) {
143- if (!module ) {
143+ if (!module_ ) {
144144 throw std::runtime_error (" Model not loaded: Cannot perform forward pass" );
145145 }
146- return module ->forward (input_evalues);
146+ return module_ ->forward (input_evalues);
147147}
148148
149149std::size_t BaseModel::getMemoryLowerBound () { return memorySizeLowerBound; }
150150
151- void BaseModel::unload () { module .reset (nullptr ); }
151+ void BaseModel::unload () { module_ .reset (nullptr ); }
152152
153153std::vector<int32_t >
154154BaseModel::getTensorShape (const executorch::aten::Tensor &tensor) {
0 commit comments