Skip to content

Commit

Permalink
Enable Ort::Value to be a resisable vector
Browse files Browse the repository at this point in the history
  • Loading branch information
yuslepukhin committed Dec 19, 2024
1 parent baeece4 commit 6fa0c00
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
12 changes: 7 additions & 5 deletions include/onnxruntime/core/platform/EigenNonBlockingThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,18 @@ class ThreadPoolProfiler {
WAIT_REVOKE,
MAX_EVENT
};
ThreadPoolProfiler(int, const CHAR_TYPE*){};
ThreadPoolProfiler(int, const CHAR_TYPE*) {};
~ThreadPoolProfiler() = default;
ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(ThreadPoolProfiler);
void Start(){};
void Start() {};
std::string Stop() { return "not available for minimal build"; }
void LogStart(){};
void LogStart() {};
void LogEnd(ThreadPoolEvent){};
void LogEndAndStart(ThreadPoolEvent){};
void LogStartAndCoreAndBlock(std::ptrdiff_t){};
void LogCoreAndBlock(std::ptrdiff_t){};
void LogThreadId(int){};
void LogRun(int){};
void LogThreadId(int) {};
void LogRun(int) {};
std::string DumpChildThreadStat() { return {}; }
};
#else
Expand Down Expand Up @@ -634,9 +634,11 @@ class RunQueue {
// position, these conditions would be indistinguishable); (2) obtain
// consistent snapshot of front_/back_ for Size operation using the
// modification counters.
#pragma warning(disable : 4324)
ORT_ALIGN_TO_AVOID_FALSE_SHARING std::atomic<unsigned> front_;
ORT_ALIGN_TO_AVOID_FALSE_SHARING std::atomic<unsigned> back_;
ORT_ALIGN_TO_AVOID_FALSE_SHARING Elem array_[kSize];
#pragma warning(default : 4324)

// SizeOrNotEmpty returns current queue size; if NeedSizeEstimate is false,
// only whether the size is 0 is guaranteed to be correct.
Expand Down
4 changes: 2 additions & 2 deletions include/onnxruntime/core/session/onnxruntime_cxx_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1294,11 +1294,11 @@ using UnownedValue = detail::ValueImpl<detail::Unowned<OrtValue>>;
*/
struct Value : detail::ValueImpl<OrtValue> {
using Base = detail::ValueImpl<OrtValue>;
using Base::Base;
using OrtSparseValuesParam = detail::OrtSparseValuesParam;
using Shape = detail::Shape;

explicit Value(std::nullptr_t) {} ///< Create an empty Value object, must be assigned a valid one to be used
explicit Value(OrtValue* p) : Base{p} {} ///< Used for interop with the C API
explicit Value(std::nullptr_t) {} ///< Create an empty Value object, must be assigned a valid one to be used
Value(Value&&) = default;
Value& operator=(Value&&) = default;

Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/providers/cuda/cu_inc/common.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace onnxruntime {
namespace cuda {

// float16 arithmetic is supported after sm5.3 with intrinsics, and cuda does not provide fallback for lower versions
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 530
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 530) && ((__CUDACC_VER_MAJOR__ < 12) || ((__CUDACC_VER_MAJOR__ == 12) && (__CUDACC_VER_MINOR__ < 2)))
__device__ __forceinline__ half operator+(const half& lh, const half& rh) { return half((float)lh + (float)rh); }
__device__ __forceinline__ half operator-(const half& lh, const half& rh) { return half((float)lh - (float)rh); }
__device__ __forceinline__ half operator*(const half& lh, const half& rh) { return half((float)lh * (float)rh); }
Expand Down
5 changes: 5 additions & 0 deletions onnxruntime/test/shared_lib/test_nontensor_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,11 @@ TEST(CApiTest, SparseTensorFillSparseTensorFormatAPI) {
}
}

TEST(CApi, TestResize) {
std::vector<Ort::Value> values;
values.resize(10);
}

TEST(CApiTest, SparseTensorFillSparseFormatStringsAPI) {
auto allocator = Ort::AllocatorWithDefaultOptions();
Ort::MemoryInfo info("Cpu", OrtDeviceAllocator, 0, OrtMemTypeDefault);
Expand Down

0 comments on commit 6fa0c00

Please sign in to comment.