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_CACHE_MEM_BASE_H_ 18 #define MINDSPORE_LITE_SRC_EXTENDRT_DELEGATE_PARAMETER_CACHE_CACHE_MEM_BASE_H_ 19 #include <utility> 20 #include <memory> 21 22 namespace mindspore { 23 namespace cache { 24 class CacheMemBase { 25 public: 26 CacheMemBase() = default; 27 virtual ~CacheMemBase() = default; 28 virtual bool InitDevice(uint32_t device_id, const void *context) = 0; 29 virtual void *MallocMemory(size_t size) = 0; 30 virtual void FreeMemory(void *buf) = 0; 31 virtual bool SynchronizeStream() = 0; 32 virtual bool CopyHostMemToDevice(void *dst, const void *src, size_t size) = 0; 33 virtual bool CopyDeviceMemToHost(void *dst, const void *src, size_t size) = 0; 34 virtual bool HashSwapOut(void *hash_table_addr, void *swap_out_value_addr, void *swap_out_index_addr, 35 size_t cache_vocab_size, size_t embedding_size, size_t swap_out_size) = 0; 36 virtual bool HashSwapIn(void *hash_table_addr, void *swap_in_value_addr, void *swap_in_index_addr, 37 size_t cache_vocab_size, size_t embedding_size, size_t swap_in_size) = 0; 38 }; 39 } // namespace cache 40 } // namespace mindspore 41 #endif // MINDSPORE_LITE_SRC_EXTENDRT_DELEGATE_PARAMETER_CACHE_CACHE_MEM_BASE_H_ 42