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_CCSRC_RUNTIME_FRAMEWORK_HOST_QUEUE_STORE_H_ 18 #define MINDSPORE_CCSRC_RUNTIME_FRAMEWORK_HOST_QUEUE_STORE_H_ 19 20 #include <memory> 21 #include <vector> 22 #include <queue> 23 #include "ir/tensor.h" 24 25 namespace mindspore { 26 namespace runtime { 27 using mindspore::tensor::TensorPtr; 28 29 // Host tensor queue is used to store host tensors(such as non weighted parameters of graph), and its data will be 30 // fetched by the host queue data source actor. 31 class HostTensorQueue { 32 public: 33 HostTensorQueue() = default; 34 virtual ~HostTensorQueue() = default; 35 Push(const std::vector<TensorPtr> & tensors)36 void Push(const std::vector<TensorPtr> &tensors) { buffers_.push(tensors); } 37 Pull()38 const std::vector<TensorPtr> &Pull() { return buffers_.front(); } 39 IsEmpty()40 bool IsEmpty() const { return buffers_.empty(); } 41 Pop()42 void Pop() { buffers_.pop(); } 43 44 private: 45 std::queue<std::vector<TensorPtr>> buffers_; 46 }; 47 48 using HostTensorQueuePtr = std::shared_ptr<HostTensorQueue>; 49 } // namespace runtime 50 } // namespace mindspore 51 52 #endif // MINDSPORE_CCSRC_RUNTIME_FRAMEWORK_HOST_QUEUE_STORE_H_ 53