@@ -29,7 +29,7 @@ BaseModel::BaseModel(const std::string &modelSource,
2929}
3030
3131std::vector<int32_t > BaseModel::getInputShape (std::string method_name,
32- int32_t index) {
32+ int32_t index) const {
3333 if (!module_) {
3434 throw std::runtime_error (" Model not loaded: Cannot get input shape" );
3535 }
@@ -87,7 +87,7 @@ BaseModel::getAllInputShapes(std::string methodName) const {
8787// / to JS. It is not meant to be used within C++. If you want to call forward
8888// / from C++ on a BaseModel, please use BaseModel::forward.
8989std::vector<JSTensorViewOut>
90- BaseModel::forwardJS (std::vector<JSTensorViewIn> tensorViewVec) {
90+ BaseModel::forwardJS (std::vector<JSTensorViewIn> tensorViewVec) const {
9191 if (!module_) {
9292 throw std::runtime_error (" Model not loaded: Cannot perform forward pass" );
9393 }
@@ -135,7 +135,7 @@ BaseModel::forwardJS(std::vector<JSTensorViewIn> tensorViewVec) {
135135}
136136
137137Result<executorch::runtime::MethodMeta>
138- BaseModel::getMethodMeta (const std::string &methodName) {
138+ BaseModel::getMethodMeta (const std::string &methodName) const {
139139 if (!module_) {
140140 throw std::runtime_error (" Model not loaded: Cannot get method meta!" );
141141 }
@@ -160,7 +160,7 @@ BaseModel::forward(const std::vector<EValue> &input_evalues) const {
160160
161161Result<std::vector<EValue>>
162162BaseModel::execute (const std::string &methodName,
163- const std::vector<EValue> &input_value) {
163+ const std::vector<EValue> &input_value) const {
164164 if (!module_) {
165165 throw std::runtime_error (" Model not loaded, cannot run execute." );
166166 }
@@ -174,7 +174,7 @@ std::size_t BaseModel::getMemoryLowerBound() const noexcept {
174174void BaseModel::unload () noexcept { module_.reset (nullptr ); }
175175
176176std::vector<int32_t >
177- BaseModel::getTensorShape (const executorch::aten::Tensor &tensor) {
177+ BaseModel::getTensorShape (const executorch::aten::Tensor &tensor) const {
178178 auto sizes = tensor.sizes ();
179179 return std::vector<int32_t >(sizes.begin (), sizes.end ());
180180}
0 commit comments