HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
buffer_deleter.h
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the MIT License.
3
4
#pragma once
5
6
#include "
core/framework/allocator.h
"
7
8
namespace
onnxruntime {
9
10
// TODO: Do we need this class or is IAllocator::MakeUniquePtr sufficient/better
11
class
BufferDeleter
{
12
public
:
13
BufferDeleter
() =
default
;
14
explicit
BufferDeleter
(
AllocatorPtr
alloc)
15
: alloc_(std::move(alloc)) {}
16
17
void
operator()
(
void
* p)
const
{
18
if
(alloc_)
19
alloc_->Free(p);
20
}
21
22
private
:
23
// TODO: we may need consider the lifetime of alloc carefully
24
// The alloc_ here is the allocator that used to allocate the buffer
25
// And need go with the unique_ptr together. If it is using our internal
26
// allocator, it is ok as our allocators are global managed. But if it
27
// is provide by user, user need to be very careful about it.
28
// A weak_ptr may be a choice to reduce the impact, but that require to
29
// change our current allocator mgr to use shared_ptr. Will revisit it
30
// later.
31
AllocatorPtr
alloc_{
nullptr
};
32
};
33
34
using
BufferUniquePtr
= std::unique_ptr<void, BufferDeleter>;
35
using
BufferNakedPtr
=
void
*;
36
}
// namespace onnxruntime
onnxruntime::BufferDeleter::BufferDeleter
BufferDeleter()=default
onnxruntime::BufferDeleter::operator()
void operator()(void *p) const
Definition:
buffer_deleter.h:17
onnxruntime::BufferUniquePtr
std::unique_ptr< void, BufferDeleter > BufferUniquePtr
Definition:
buffer_deleter.h:34
onnxruntime::BufferNakedPtr
void * BufferNakedPtr
Definition:
buffer_deleter.h:35
onnxruntime::AllocatorPtr
std::shared_ptr< IAllocator > AllocatorPtr
Definition:
allocator.h:261
onnxruntime::BufferDeleter::BufferDeleter
BufferDeleter(AllocatorPtr alloc)
Definition:
buffer_deleter.h:14
allocator.h
onnxruntime::BufferDeleter
Definition:
buffer_deleter.h:11
onnxruntime
core
framework
buffer_deleter.h
Generated on Thu Nov 21 2024 02:43:53 for HDK by
1.8.6