mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-29 23:06:41 +00:00
### Description
Run clang-format in CI. Formatted all c/c++, objective-c/c++ files.
Excluded
```
'onnxruntime/core/mlas/**',
'onnxruntime/contrib_ops/cuda/bert/tensorrt_fused_multihead_attention/**',
```
because they contain assembly or is data heavy
### Motivation and Context
Coding style consistency
34 lines
1.4 KiB
C++
34 lines
1.4 KiB
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#include "core/session/onnxruntime_cxx_api.h"
|
|
#include "core/providers/cpu/cpu_provider_factory.h"
|
|
#include <gtest/gtest.h>
|
|
|
|
TEST(CApiTest, allocation_info) {
|
|
auto cpu_mem_info_1 = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault);
|
|
auto cpu_mem_info_2 = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault);
|
|
ASSERT_EQ(cpu_mem_info_1, cpu_mem_info_2);
|
|
|
|
ASSERT_EQ(OrtMemoryInfoDeviceType::OrtMemoryInfoDeviceType_CPU, cpu_mem_info_1.GetDeviceType());
|
|
ASSERT_EQ(OrtMemoryInfoDeviceType::OrtMemoryInfoDeviceType_CPU, cpu_mem_info_2.GetDeviceType());
|
|
|
|
ASSERT_EQ("Cpu", cpu_mem_info_1.GetAllocatorName());
|
|
ASSERT_EQ(OrtArenaAllocator, cpu_mem_info_1.GetAllocatorType());
|
|
ASSERT_EQ(OrtMemTypeDefault, cpu_mem_info_1.GetMemoryType());
|
|
}
|
|
|
|
TEST(CApiTest, DefaultAllocator) {
|
|
Ort::AllocatorWithDefaultOptions default_allocator;
|
|
auto cpu_info = default_allocator.GetInfo();
|
|
|
|
ASSERT_EQ("Cpu", cpu_info.GetAllocatorName());
|
|
ASSERT_EQ(OrtMemoryInfoDeviceType::OrtMemoryInfoDeviceType_CPU, cpu_info.GetDeviceType());
|
|
ASSERT_EQ(OrtDeviceAllocator, cpu_info.GetAllocatorType());
|
|
ASSERT_EQ(OrtMemTypeDefault, cpu_info.GetMemoryType());
|
|
|
|
Ort::MemoryAllocation allocation(default_allocator, default_allocator.Alloc(100), 100);
|
|
ASSERT_EQ(allocation.size(), 100U);
|
|
ASSERT_NE(allocation.get(), nullptr);
|
|
memset(allocation.get(), 0, 100U);
|
|
}
|