-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expose knobs to create and share (CPU) allocators across sessions in C# and Python #5634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
91206eb
0e01c2b
8cc4ca1
9b6d0e5
b7d88a2
555328a
6e49685
5b52f4b
daa5df5
74972f6
355dc66
3a948e5
6d16d92
95a7e54
11baa33
8a79299
05cfe16
6df325f
1776a4f
e0e075d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,15 +143,6 @@ typedef enum OrtErrorCode { | |
| ORT_EP_FAIL, | ||
| } OrtErrorCode; | ||
|
|
||
| // This configures the arena based allocator used by ORT | ||
| // See docs/C_API.md for details on what these mean and how to choose these values | ||
| typedef struct OrtArenaCfg { | ||
hariharans29 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| size_t max_mem; // use 0 to allow ORT to choose the default | ||
| int arena_extend_strategy; // use -1 to allow ORT to choose the default, 0 = kNextPowerOfTwo, 1 = kSameAsRequested | ||
| int initial_chunk_size_bytes; // use -1 to allow ORT to choose the default | ||
| int max_dead_bytes_per_chunk; // use -1 to allow ORT to choose the default | ||
| } OrtArenaCfg; | ||
|
|
||
| #define ORT_RUNTIME_CLASS(X) \ | ||
| struct Ort##X; \ | ||
| typedef struct Ort##X Ort##X; | ||
|
|
@@ -173,6 +164,7 @@ ORT_RUNTIME_CLASS(SequenceTypeInfo); | |
| ORT_RUNTIME_CLASS(ModelMetadata); | ||
| ORT_RUNTIME_CLASS(ThreadPoolParams); | ||
| ORT_RUNTIME_CLASS(ThreadingOptions); | ||
| ORT_RUNTIME_CLASS(ArenaCfg); | ||
|
|
||
| #ifdef _WIN32 | ||
| typedef _Return_type_success_(return == 0) OrtStatus* OrtStatusPtr; | ||
|
|
@@ -1126,6 +1118,22 @@ struct OrtApi { | |
| * and that's recommended because turning this option on may hurt model accuracy. | ||
| */ | ||
| ORT_API2_STATUS(SetGlobalDenormalAsZero, _Inout_ OrtThreadingOptions* tp_options); | ||
|
|
||
| /** | ||
| * Use this API to create the configuration of an arena that can eventually be used to define | ||
| * an arena based allocator's behavior | ||
| * \param max_mem - use 0 to allow ORT to choose the default | ||
| * \param arena_extend_strategy - use -1 to allow ORT to choose the default, 0 = kNextPowerOfTwo, 1 = kSameAsRequested | ||
| * \param initial_chunk_size_bytes - use -1 to allow ORT to choose the default | ||
| * \param max_dead_bytes_per_chunk - use -1 to allow ORT to choose the default | ||
hariharans29 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * \param out - a pointer to an OrtArenaCfg instance | ||
| * \return a nullptr in case of success or a pointer to an OrtStatus instance in case of failure | ||
| * See docs/C_API.md for details on what the following parameters mean and how to choose these values | ||
| */ | ||
| ORT_API2_STATUS(CreateArenaCfg, _In_ size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, | ||
pranavsharma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| int max_dead_bytes_per_chunk, _Outptr_ OrtArenaCfg** out); | ||
|
|
||
| ORT_CLASS_RELEASE(ArenaCfg); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Normally, this would be declared automatically
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How so ? |
||
| }; | ||
|
|
||
| /* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,6 +98,7 @@ ORT_DEFINE_RELEASE(Value); | |
| ORT_DEFINE_RELEASE(ModelMetadata); | ||
| ORT_DEFINE_RELEASE(ThreadingOptions); | ||
| ORT_DEFINE_RELEASE(IoBinding); | ||
| ORT_DEFINE_RELEASE(ArenaCfg); | ||
|
|
||
| /*! \class Ort::Float16_t | ||
| * \brief it is a structure that represents float16 data. | ||
|
|
@@ -551,6 +552,23 @@ struct IoBinding : public Base<OrtIoBinding> { | |
| void ClearBoundOutputs(); | ||
| }; | ||
|
|
||
| /*! \struct Ort::ArenaCfg | ||
| * \brief it is a structure that represents the configuration of an arena based allocator | ||
| * \details Please see docs/C_API.md for details | ||
| */ | ||
| struct ArenaCfg : Base<OrtArenaCfg> { | ||
hariharans29 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| explicit ArenaCfg(std::nullptr_t) {} | ||
| /** | ||
| * \param max_mem - use 0 to allow ORT to choose the default | ||
| * \param arena_extend_strategy - use -1 to allow ORT to choose the default, 0 = kNextPowerOfTwo, 1 = kSameAsRequested | ||
| * \param initial_chunk_size_bytes - use -1 to allow ORT to choose the default | ||
| * \param max_dead_bytes_per_chunk - use -1 to allow ORT to choose the default | ||
| * \return an instance of ArenaCfg | ||
| * See docs/C_API.md for details on what the following parameters mean and how to choose these values | ||
| */ | ||
| ArenaCfg(size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, int max_dead_bytes_per_chunk); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
perhaps a factory method would be a good idea?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But why though ? Why move from an established pattern ? Can you please elaborate on why it will be a good idea for this ? |
||
| }; | ||
|
|
||
| // | ||
| // Custom OPs (only needed to implement custom OPs) | ||
| // | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.