From 7c70d9349a8e176eaff3f9774e9f1da4b659f2d0 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 6 Feb 2019 15:19:06 -0800 Subject: [PATCH] Fix a bug in execution_provider.cc --- include/onnxruntime/core/session/onnxruntime_c_api.h | 3 ++- onnxruntime/core/framework/execution_provider.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h index b6c51baa90..49b924f0a6 100644 --- a/include/onnxruntime/core/session/onnxruntime_c_api.h +++ b/include/onnxruntime/core/session/onnxruntime_c_api.h @@ -373,7 +373,8 @@ typedef enum OrtAllocatorType { } OrtAllocatorType; /** - memory types for allocator, exec provider specific types should be extended in each provider + * memory types for allocator, exec provider specific types should be extended in each provider + * Whenever this struct is updated, please also update the MakeKey function in onnxruntime/core/framework/execution_provider.cc */ typedef enum OrtMemType { OrtMemTypeCPUInput = -2, // Any CPU memory used by non-CPU execution provider diff --git a/onnxruntime/core/framework/execution_provider.cc b/onnxruntime/core/framework/execution_provider.cc index b3be350c2c..a0bd30bae1 100644 --- a/onnxruntime/core/framework/execution_provider.cc +++ b/onnxruntime/core/framework/execution_provider.cc @@ -11,8 +11,9 @@ namespace onnxruntime { namespace { +//It assumes max(OrtMemType) <= 1, min(OrtMemType) = -2 inline int MakeKey(int id, OrtMemType mem_type) { - return id << 2 | mem_type; + return id << 2 | (mem_type + 2); } } // namespace