1 /** 2 * Copyright 2021 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_LITE_SRC_EXTENDRT_DELEGATE_PARAMETER_CACHE_LOAD_HOST_CACHE_MODEL_H_ 18 #define MINDSPORE_LITE_SRC_EXTENDRT_DELEGATE_PARAMETER_CACHE_LOAD_HOST_CACHE_MODEL_H_ 19 20 #include <map> 21 #include <string> 22 #include "include/api/status.h" 23 #include "include/api/data_type.h" 24 #include "include/api/types.h" 25 #include "include/api/kernel.h" 26 #include "include/api/delegate.h" 27 #include "src/litert/lite_model.h" 28 29 namespace mindspore { 30 namespace cache { 31 class HostCacheModel { 32 public: 33 HostCacheModel() = default; 34 ~HostCacheModel(); 35 Status LoadCache(const std::string &model_path); 36 Status LoadCache(DelegateModel<schema::Primitive> *model); 37 bool CheckIsCacheKernel(kernel::Kernel *kernel); 38 MSTensor GetHostCacheTensor(kernel::Kernel *kernel); 39 40 private: 41 std::map<std::string, MSTensor> cache_tensor_; 42 mindspore::lite::LiteModel *cache_model_{nullptr}; 43 char *model_buf_{nullptr}; 44 size_t model_size_; 45 }; 46 } // namespace cache 47 } // namespace mindspore 48 #endif // MINDSPORE_LITE_EMBEDDING_CACHE_H_ 49