mxnet
storage.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
24 #ifndef MXNET_STORAGE_H_
25 #define MXNET_STORAGE_H_
26 
27 #include <memory>
28 #include "./base.h"
29 
30 namespace mxnet {
31 
35 class Storage {
36  public:
40  struct Handle {
44  void* dptr;
48  size_t size;
53  };
60  virtual Handle Alloc(size_t size, Context ctx) = 0;
65  virtual void Free(Handle handle) = 0;
75  virtual void DirectFree(Handle handle) = 0;
79  virtual ~Storage() {}
83  static Storage* Get();
92  static std::shared_ptr<Storage> _GetSharedRef();
93 }; // class Storage
94 } // namespace mxnet
95 #endif // MXNET_STORAGE_H_
virtual void DirectFree(Handle handle)=0
Free storage directly, without putting it into memory pool. This can synchronization of all previous ...
static std::shared_ptr< Storage > _GetSharedRef()
Get shared pointer reference to storage singleton. Most user should not call this function...
namespace of mxnet
Definition: base.h:126
Storage manager across multiple devices.
Definition: storage.h:35
virtual ~Storage()
Destructor.
Definition: storage.h:79
virtual void Free(Handle handle)=0
Free storage.
void * dptr
Pointer to the data.
Definition: storage.h:44
Context ctx
Context information about device and ID.
Definition: storage.h:52
virtual Handle Alloc(size_t size, Context ctx)=0
Allocate a new contiguous memory for a given size.
static Storage * Get()
Storage handle.
Definition: storage.h:40
size_t size
Size of the storage.
Definition: storage.h:48
Context information about the execution environment.
Definition: base.h:141