shared_buffer.hpp
1 //*****************************************************************************
2 // Copyright 2017-2021 Intel Corporation
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 #pragma once
18 
19 #include <cstddef>
20 
21 #include "ngraph/runtime/aligned_buffer.hpp"
22 
23 namespace ngraph
24 {
25  namespace runtime
26  {
27  /// \brief SharedBuffer class to store pointer to pre-acclocated buffer.
28  template <typename T>
30  {
31  public:
32  SharedBuffer(char* data, size_t size, T& shared_object)
33  : _shared_object(shared_object)
34  {
35  m_allocated_buffer = data;
36  m_aligned_buffer = data;
37  m_byte_size = size;
38  }
39 
40  virtual ~SharedBuffer()
41  {
42  m_aligned_buffer = nullptr;
43  m_allocated_buffer = nullptr;
44  m_byte_size = 0;
45  }
46 
47  private:
48  T _shared_object;
49  };
50  }
51 }
Allocates a block of memory on the specified alignment. The actual size of the allocated memory is la...
Definition: aligned_buffer.hpp:32
SharedBuffer class to store pointer to pre-acclocated buffer.
Definition: shared_buffer.hpp:30
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28