mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-08 17:17:15 +00:00
* added packaging pipeline * Update win-ci-pipeline.yml for Azure Pipelines * Update win-ci-pipeline.yml for Azure Pipelines * Update win-ci-pipeline.yml for Azure Pipelines * Update win-ci-pipeline.yml for Azure Pipelines * Update win-ci-pipeline.yml for Azure Pipelines * Update win-ci-pipeline.yml for Azure Pipelines * Update win-ci-pipeline.yml for Azure Pipelines * Update win-ci-pipeline.yml for Azure Pipelines * put the c-api header file at root instead of under core/session * Update win-ci-pipeline.yml for Azure Pipelines * Update win-ci-pipeline.yml for Azure Pipelines * Update win-ci-pipeline.yml for Azure Pipelines * parameterize the windows build script * Update win-package-pipeline.yml for Azure Pipelines * fixed indenting * fixed indenting * fix parameter reference syntax * try using arch = amd64 for the vcvarsall * remove duplicate tasks * use vcvarsall * some more refactor * fix typo * fix typo * factored out the packaging step into a template * add x86 build to package pipeline * use amd64 for vcvars arg * added gpu pipeline. added msbuild platform param * fix the msbuild platform * use amd64 host for x86 build * use buildarch=x86 for vcvarsall * remove vcvars from setup steps * add some logging for PNG lib, and disable fns_candy demo for win32 * set allocator alignment to 32 bit for win32 compiler * disable parallel execution test for x86 * use 64 bit toolchain for x86 build * add missing -T flag for toolset * fix string delimietr in workingdirectory name for package build test step * fix gpu pipeline * make io_types test conditional * use cuda 10 instead of cuda 9.1, similar to the ci build * try some workaround on the io test * undo inadvertent local change in build.py, also reenable the io test * make all test run single threaded * blacklist few failing tests for x86 * added some log in build.py * edit build.py to disable parallel test * add the failed tests into the blacklist for win32 * add tf_pasnet_large to blacklist * change control flow for build.py onnx tests * add README, license and TPN to the package * updated build.py test sequence for parallel executor * updated onnx test flow as per review comment * add type checking log in the compare_mlvalue * fix type cast * blacklist some failed test as of now * one more blacklisted test
82 lines
1.9 KiB
C++
82 lines
1.9 KiB
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#include "core/framework/allocator.h"
|
|
#include "core/framework/allocatormgr.h"
|
|
#include <cstdlib>
|
|
#include <sstream>
|
|
#include <cstdlib>
|
|
|
|
namespace onnxruntime {
|
|
|
|
void* CPUAllocator::Alloc(size_t size) {
|
|
if (size <= 0)
|
|
return nullptr;
|
|
//default align to 64;
|
|
void* p;
|
|
#ifdef _WIN32
|
|
size_t alignment = 32;
|
|
#else
|
|
size_t alignment = 64;
|
|
#endif
|
|
#if _MSC_VER
|
|
p = _aligned_malloc(size, alignment);
|
|
if (p == nullptr) throw std::bad_alloc();
|
|
#elif defined(_LIBCPP_SGX_CONFIG)
|
|
p = memalign(alignment, size);
|
|
if (p == nullptr) throw std::bad_alloc();
|
|
#else
|
|
int ret = posix_memalign(&p, alignment, size);
|
|
if (ret != 0) throw std::bad_alloc();
|
|
#endif
|
|
return p;
|
|
}
|
|
|
|
void CPUAllocator::Free(void* p) {
|
|
#if _MSC_VER
|
|
_aligned_free(p);
|
|
#else
|
|
free(p);
|
|
#endif
|
|
}
|
|
|
|
const OrtAllocatorInfo& CPUAllocator::Info() const {
|
|
return *allocator_info_;
|
|
}
|
|
} // namespace onnxruntime
|
|
|
|
std::ostream& operator<<(std::ostream& out, const OrtAllocatorInfo& info) {
|
|
return (out << info.ToString());
|
|
}
|
|
|
|
ORT_API_STATUS_IMPL(OrtCreateAllocatorInfo, const char* name1, OrtAllocatorType type, int id1, OrtMemType mem_type1, OrtAllocatorInfo** out) {
|
|
*out = new OrtAllocatorInfo(name1, type, id1, mem_type1);
|
|
return nullptr;
|
|
}
|
|
|
|
ORT_API(void, OrtReleaseAllocatorInfo, OrtAllocatorInfo* p) {
|
|
delete p;
|
|
}
|
|
|
|
ORT_API(const char*, OrtAllocatorInfoGetName, _In_ OrtAllocatorInfo* ptr) {
|
|
return ptr->name;
|
|
}
|
|
|
|
ORT_API(int, OrtAllocatorInfoGetId, _In_ OrtAllocatorInfo* ptr) {
|
|
return ptr->id;
|
|
}
|
|
|
|
ORT_API(OrtMemType, OrtAllocatorInfoGetMemType, _In_ OrtAllocatorInfo* ptr) {
|
|
return ptr->mem_type;
|
|
}
|
|
|
|
ORT_API(OrtAllocatorType, OrtAllocatorInfoGetType, _In_ OrtAllocatorInfo* ptr) {
|
|
return ptr->type;
|
|
}
|
|
|
|
ORT_API(int, OrtCompareAllocatorInfo, _In_ const OrtAllocatorInfo* info1, _In_ const OrtAllocatorInfo* info2) {
|
|
if (*info1 == *info2) {
|
|
return 0;
|
|
}
|
|
return -1;
|
|
}
|