Skip to content

Commit 0200048

Browse files
committed
chore: rename module to module_ to avoid potential conflicts
1 parent ae996fb commit 0200048

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

packages/react-native-executorch/common/rnexecutorch/models/BaseModel.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ using ::executorch::runtime::Error;
1313
BaseModel::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

3131
std::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

5757
std::vector<std::vector<int32_t>>
5858
BaseModel::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

8686
std::vector<JSTensorViewOut>
8787
BaseModel::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

134134
Result<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

141141
Result<std::vector<EValue>>
142142
BaseModel::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

149149
std::size_t BaseModel::getMemoryLowerBound() { return memorySizeLowerBound; }
150150

151-
void BaseModel::unload() { module.reset(nullptr); }
151+
void BaseModel::unload() { module_.reset(nullptr); }
152152

153153
std::vector<int32_t>
154154
BaseModel::getTensorShape(const executorch::aten::Tensor &tensor) {

packages/react-native-executorch/common/rnexecutorch/models/BaseModel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class BaseModel {
3333
// (unnecessary copies instead of working on JS memory). In this case
3434
// CallInvoker can be used to get jsi::Runtime, and use it in a safe manner.
3535
std::shared_ptr<react::CallInvoker> callInvoker;
36-
std::unique_ptr<executorch::extension::Module> module;
36+
std::unique_ptr<executorch::extension::Module> module_;
3737

3838
private:
3939
std::size_t memorySizeLowerBound{0};

0 commit comments

Comments
 (0)