HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
alloc_kind.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 #include <iosfwd>
6 
7 namespace onnxruntime {
8 // The ml-Values fall into the following categories with respect to their
9 // memory management:
10 // - inference inputs: owned (allocated and freed) by caller, and is by
11 // default read-only by the runtime.
12 // - inference outputs: allocated by runtime, ownership transferred to
13 // caller. TODO: Make sure this semantics is clear in InferenceSession API.
14 // - weights (constant tensors): can be allocated once (statically), and
15 // reused by all inference calls within an InferenceSession.
16 // - tensor values: The lifetimes of these tensor-values are statically
17 // determined, which is used for memory reuse/sharing optimizations. The
18 // runtime allocates/frees these values at the right time (as determined
19 // by the static allocation plan). Note that this is simplified since we
20 // do not try to optimize for "slice" like ops, where we may be able to
21 // conditionally reuse memory/data in some cases but not others.
22 // Generalizing this is future work.
23 
24 enum class AllocKind {
25  kNotSet = -1,
26  kAllocate = 0,
27  kReuse = 1,
28  kPreExisting = 2,
30  kAllocateOutput = 4,
31  kShare = 5,
33 };
34 
35 std::ostream& operator<<(std::ostream& out, AllocKind alloc_kind);
36 } // namespace onnxruntime
std::ostream & operator<<(std::ostream &out, AllocKind alloc_kind)