@@ -30,7 +30,7 @@ BaseModel::BaseModel(const std::string &modelSource,
3030}
3131
3232std::vector<int32_t > BaseModel::getInputShape (std::string method_name,
33- int32_t index) {
33+ int32_t index) const {
3434 if (!module_) {
3535 throw std::runtime_error (" Model not loaded: Cannot get input shape" );
3636 }
@@ -88,7 +88,7 @@ BaseModel::getAllInputShapes(std::string methodName) const {
8888// / to JS. It is not meant to be used within C++. If you want to call forward
8989// / from C++ on a BaseModel, please use BaseModel::forward.
9090std::vector<JSTensorViewOut>
91- BaseModel::forwardJS (std::vector<JSTensorViewIn> tensorViewVec) {
91+ BaseModel::forwardJS (std::vector<JSTensorViewIn> tensorViewVec) const {
9292 if (!module_) {
9393 throw std::runtime_error (" Model not loaded: Cannot perform forward pass" );
9494 }
@@ -136,7 +136,7 @@ BaseModel::forwardJS(std::vector<JSTensorViewIn> tensorViewVec) {
136136}
137137
138138Result<executorch::runtime::MethodMeta>
139- BaseModel::getMethodMeta (const std::string &methodName) {
139+ BaseModel::getMethodMeta (const std::string &methodName) const {
140140 if (!module_) {
141141 throw std::runtime_error (" Model not loaded: Cannot get method meta!" );
142142 }
@@ -161,7 +161,7 @@ BaseModel::forward(const std::vector<EValue> &input_evalues) const {
161161
162162Result<std::vector<EValue>>
163163BaseModel::execute (const std::string &methodName,
164- const std::vector<EValue> &input_value) {
164+ const std::vector<EValue> &input_value) const {
165165 if (!module_) {
166166 throw std::runtime_error (" Model not loaded, cannot run execute." );
167167 }
@@ -175,7 +175,7 @@ std::size_t BaseModel::getMemoryLowerBound() const noexcept {
175175void BaseModel::unload () noexcept { module_.reset (nullptr ); }
176176
177177std::vector<int32_t >
178- BaseModel::getTensorShape (const executorch::aten::Tensor &tensor) {
178+ BaseModel::getTensorShape (const executorch::aten::Tensor &tensor) const {
179179 auto sizes = tensor.sizes ();
180180 return std::vector<int32_t >(sizes.begin (), sizes.end ());
181181}
0 commit comments