Internal change

PiperOrigin-RevId: 336772472
Change-Id: If842b01f1599639a53214b9ed286b9be892fd9ba
This commit is contained in:
A. Unique TensorFlower 2020-10-12 16:48:36 -07:00 committed by TensorFlower Gardener
parent a05f8bdf0e
commit 3d657bfd84

View File

@ -36,7 +36,7 @@ namespace cl {
#ifdef __ANDROID__
#define LoadFunction(function) \
if (is_pixel) { \
if (use_wrapper) { \
function = reinterpret_cast<PFN_##function>(loadOpenCLPointer(#function)); \
} else { \
function = reinterpret_cast<PFN_##function>(dlsym(libopencl, #function)); \
@ -53,7 +53,7 @@ namespace cl {
#ifdef __WINDOWS__
void LoadOpenCLFunctions(HMODULE libopencl);
#else
void LoadOpenCLFunctions(void* libopencl, bool is_pixel);
void LoadOpenCLFunctions(void* libopencl, bool use_wrapper);
#endif
absl::Status LoadOpenCL() {
@ -77,8 +77,11 @@ absl::Status LoadOpenCL() {
// record error
std::string error(dlerror());
#ifdef __ANDROID__
// Pixel phone?
// Pixel phone or auto?
libopencl = dlopen("libOpenCL-pixel.so", RTLD_NOW | RTLD_LOCAL);
if (!libopencl) {
libopencl = dlopen("libOpenCL-car.so", RTLD_NOW | RTLD_LOCAL);
}
if (libopencl) {
typedef void (*enableOpenCL_t)();
enableOpenCL_t enableOpenCL =
@ -96,11 +99,11 @@ absl::Status LoadOpenCL() {
#ifdef __WINDOWS__
void LoadOpenCLFunctions(HMODULE libopencl) {
#else
void LoadOpenCLFunctions(void* libopencl, bool is_pixel) {
void LoadOpenCLFunctions(void* libopencl, bool use_wrapper) {
#ifdef __ANDROID__
typedef void* (*loadOpenCLPointer_t)(const char* name);
loadOpenCLPointer_t loadOpenCLPointer;
if (is_pixel) {
if (use_wrapper) {
loadOpenCLPointer = reinterpret_cast<loadOpenCLPointer_t>(
dlsym(libopencl, "loadOpenCLPointer"));
}