[XROS][ML] System specific adjustments for UTs to work. (#65245)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65245

Building and running c10 and qnnpack tests on XROS.

Notable changes:
- Adding #if define(_XROS_) in few places not supported by XROS
- Changing Threadpool to abstract class
ghstack-source-id: 139513579

Test Plan: Run c10 and qnnpack tests on XROS.

Reviewed By: veselinp, iseeyuan

Differential Revision: D30137333

fbshipit-source-id: bb6239b935187fac712834341fe5a8d3377762b1
This commit is contained in:
Karol Kosik
2021-10-01 18:13:39 -07:00
committed by Facebook GitHub Bot
parent 363ccb257d
commit eb3b9fe719
9 changed files with 62 additions and 38 deletions

View File

@ -2,7 +2,7 @@
#include "caffe2/utils/threadpool/pthreadpool-cpp.h"
#include "caffe2/utils/threadpool/ThreadPool.h"
#ifdef USE_PTHREADPOOL
#if defined(USE_PTHREADPOOL) && !(defined(__XROS__))
namespace caffe2 {
namespace {
static thread_local bool using_new_threadpool{false};
@ -34,7 +34,7 @@ void legacy_pthreadpool_compute_1d(
}
return;
}
#ifdef USE_PTHREADPOOL
#if defined(USE_PTHREADPOOL) && !(defined(__XROS__))
if (caffe2::using_new_threadpool) {
pthreadpool_parallelize_1d(threadpool, function, argument, range, 0u);
} else {
@ -76,7 +76,7 @@ legacy_pthreadpool_t legacy_pthreadpool_create(size_t threads_count) {
std::mutex thread_pool_creation_mutex_;
std::lock_guard<std::mutex> guard(thread_pool_creation_mutex_);
return reinterpret_cast<legacy_pthreadpool_t>(new caffe2::ThreadPool(threads_count));
return reinterpret_cast<legacy_pthreadpool_t>(caffe2::ThreadPool::createThreadPool(threads_count));
}
void legacy_pthreadpool_destroy(legacy_pthreadpool_t pthreadpool) {