1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_STREAM_EXECUTOR_HOST_BUFFER_H_ 17 #define TENSORFLOW_STREAM_EXECUTOR_HOST_BUFFER_H_ 18 19 #include "tensorflow/stream_executor/dnn.h" 20 21 namespace perftools { 22 namespace gputools { 23 24 // A HostBuffer is a block of memory in host memory containing the data for a 25 // dnn::BatchDescriptor using a device-dependent memory layout. 26 // Derived classes provide methods to construct a HostBuffer for a specific 27 // device, and to copy data in and out of the buffer. 28 class HostBuffer { 29 public: descriptor()30 const dnn::BatchDescriptor& descriptor() const { return descriptor_; } 31 32 // Returns a string describing the HostBuffer. 33 virtual string AsString() const = 0; 34 35 protected: 36 // Construct a HostBuffer from the supplied dnn::BatchDescriptor. HostBuffer(const dnn::BatchDescriptor & descriptor)37 explicit HostBuffer(const dnn::BatchDescriptor& descriptor) 38 : descriptor_(descriptor) {} ~HostBuffer()39 virtual ~HostBuffer() {} 40 41 private: 42 const dnn::BatchDescriptor descriptor_; 43 }; 44 45 } // namespace gputools 46 } // namespace perftools 47 48 #endif // TENSORFLOW_STREAM_EXECUTOR_HOST_BUFFER_H_ 49