From ea89e304395107bced95bf540adb58acf9523d86 Mon Sep 17 00:00:00 2001 From: Ray Hernandez Date: Wed, 4 Aug 2021 23:46:41 +0000 Subject: [PATCH] Revert "Making NN hardware interface libs "host supported"" Revert "Making NNAPI libraries and tests host supported" Revert submission 1769046-neuralnetworks_host_build Reason for revert: New Build Breakage Reverted Changes: Ib54d5c274:Making NNAPI libraries and tests host supported I1d7c66516:Making NN hardware interface libs "host supported"... Change-Id: I6f65774325889c50b9f8bbab13b557705419b6cf --- neuralnetworks/1.0/utils/Android.bp | 7 +----- neuralnetworks/1.0/vts/functional/Android.bp | 24 ++++++++++++------- neuralnetworks/1.1/utils/Android.bp | 7 +----- neuralnetworks/1.1/vts/functional/Android.bp | 9 +++---- neuralnetworks/1.2/utils/Android.bp | 17 +------------ neuralnetworks/1.3/utils/Android.bp | 17 +------------ neuralnetworks/aidl/Android.bp | 1 - neuralnetworks/aidl/utils/Android.bp | 20 ++-------------- neuralnetworks/aidl/utils/src/Conversions.cpp | 24 ++----------------- neuralnetworks/utils/common/Android.bp | 13 ++-------- .../utils/common/src/CommonUtils.cpp | 24 ++----------------- 11 files changed, 30 insertions(+), 133 deletions(-) diff --git a/neuralnetworks/1.0/utils/Android.bp b/neuralnetworks/1.0/utils/Android.bp index 8c51c67421..0ad9926df5 100644 --- a/neuralnetworks/1.0/utils/Android.bp +++ b/neuralnetworks/1.0/utils/Android.bp @@ -44,7 +44,6 @@ cc_library_static { cc_test { name: "neuralnetworks_utils_hal_1_0_test", - host_supported: true, srcs: ["test/*.cpp"], static_libs: [ "android.hardware.neuralnetworks@1.0", @@ -63,12 +62,8 @@ cc_test { "libhidlbase", "libhidlmemory", "liblog", + "libnativewindow", "libutils", ], - target: { - android: { - shared_libs: ["libnativewindow"], - }, - }, test_suites: ["general-tests"], } diff --git a/neuralnetworks/1.0/vts/functional/Android.bp b/neuralnetworks/1.0/vts/functional/Android.bp index b33c581a34..9a91560fea 100644 --- a/neuralnetworks/1.0/vts/functional/Android.bp +++ b/neuralnetworks/1.0/vts/functional/Android.bp @@ -25,10 +25,19 @@ package { cc_defaults { name: "neuralnetworks_vts_functional_defaults", - defaults: [ - "VtsHalTargetTestDefaults", - "neuralnetworks_float16", - ], + defaults: ["VtsHalTargetTestDefaults"], + arch: { + x86: { + cflags: [ "-D_Float16=__fp16", + "-Xclang", "-fnative-half-type", + "-Xclang", "-fallow-half-arguments-and-returns" ], + }, + x86_64: { + cflags: [ "-D_Float16=__fp16", + "-Xclang", "-fnative-half-type", + "-Xclang", "-fallow-half-arguments-and-returns" ], + }, + }, } cc_library_static { @@ -74,7 +83,6 @@ cc_test { "libnativewindow", ], static_libs: [ - "VtsHalNeuralNetworksV1_0_utils", "android.hardware.neuralnetworks@1.0", "android.hidl.allocator@1.0", "android.hidl.memory@1.0", @@ -82,6 +90,7 @@ cc_test { "libhidlmemory", "libneuralnetworks_generated_test_harness", "libneuralnetworks_utils", + "VtsHalNeuralNetworksV1_0_utils", ], whole_static_libs: [ "neuralnetworks_generated_V1_0_example", @@ -89,8 +98,5 @@ cc_test { header_libs: [ "libneuralnetworks_headers", ], - test_suites: [ - "general-tests", - "vts", - ], + test_suites: ["general-tests", "vts"], } diff --git a/neuralnetworks/1.1/utils/Android.bp b/neuralnetworks/1.1/utils/Android.bp index 737ff58159..d9e82d47b4 100644 --- a/neuralnetworks/1.1/utils/Android.bp +++ b/neuralnetworks/1.1/utils/Android.bp @@ -46,7 +46,6 @@ cc_library_static { cc_test { name: "neuralnetworks_utils_hal_1_1_test", - host_supported: true, srcs: ["test/*.cpp"], static_libs: [ "android.hardware.neuralnetworks@1.0", @@ -67,12 +66,8 @@ cc_test { "libhidlbase", "libhidlmemory", "liblog", + "libnativewindow", "libutils", ], - target: { - android: { - shared_libs: ["libnativewindow"], - }, - }, test_suites: ["general-tests"], } diff --git a/neuralnetworks/1.1/vts/functional/Android.bp b/neuralnetworks/1.1/vts/functional/Android.bp index c0011121d6..826ba9629c 100644 --- a/neuralnetworks/1.1/vts/functional/Android.bp +++ b/neuralnetworks/1.1/vts/functional/Android.bp @@ -28,19 +28,18 @@ cc_test { defaults: ["neuralnetworks_vts_functional_defaults"], srcs: [ "BasicTests.cpp", - "GeneratedTestHarness.cpp", "TestAssertions.cpp", "TestMain.cpp", "ValidateModel.cpp", "ValidateRequest.cpp", "VtsHalNeuralnetworks.cpp", + "GeneratedTestHarness.cpp", ], shared_libs: [ "libfmq", "libnativewindow", ], static_libs: [ - "VtsHalNeuralNetworksV1_0_utils", "android.hardware.neuralnetworks@1.0", "android.hardware.neuralnetworks@1.1", "android.hidl.allocator@1.0", @@ -49,6 +48,7 @@ cc_test { "libhidlmemory", "libneuralnetworks_generated_test_harness", "libneuralnetworks_utils", + "VtsHalNeuralNetworksV1_0_utils", ], whole_static_libs: [ "neuralnetworks_generated_V1_0_example", @@ -57,8 +57,5 @@ cc_test { header_libs: [ "libneuralnetworks_headers", ], - test_suites: [ - "general-tests", - "vts", - ], + test_suites: ["general-tests", "vts"], } diff --git a/neuralnetworks/1.2/utils/Android.bp b/neuralnetworks/1.2/utils/Android.bp index 4eefb0f7dc..41281ee955 100644 --- a/neuralnetworks/1.2/utils/Android.bp +++ b/neuralnetworks/1.2/utils/Android.bp @@ -50,21 +50,10 @@ cc_library_static { cflags: ["-DNN_DEBUGGABLE"], }, }, - target: { - host: { - cflags: [ - "-D__INTRODUCED_IN(x)=", - "-D__assert(a,b,c)=", - // We want all the APIs to be available on the host. - "-D__ANDROID_API__=10000", - ], - }, - }, } cc_test { name: "neuralnetworks_utils_hal_1_2_test", - host_supported: true, srcs: ["test/*.cpp"], static_libs: [ "android.hardware.neuralnetworks@1.0", @@ -87,12 +76,8 @@ cc_test { "libhidlbase", "libhidlmemory", "liblog", + "libnativewindow", "libutils", ], - target: { - android: { - shared_libs: ["libnativewindow"], - }, - }, test_suites: ["general-tests"], } diff --git a/neuralnetworks/1.3/utils/Android.bp b/neuralnetworks/1.3/utils/Android.bp index 7acb4fcb30..28c036a8ea 100644 --- a/neuralnetworks/1.3/utils/Android.bp +++ b/neuralnetworks/1.3/utils/Android.bp @@ -47,21 +47,10 @@ cc_library_static { export_static_lib_headers: [ "neuralnetworks_utils_hal_common", ], - target: { - host: { - cflags: [ - "-D__INTRODUCED_IN(x)=", - "-D__assert(a,b,c)=", - // We want all the APIs to be available on the host. - "-D__ANDROID_API__=10000", - ], - }, - }, } cc_test { name: "neuralnetworks_utils_hal_1_3_test", - host_supported: true, srcs: ["test/*.cpp"], static_libs: [ "android.hardware.neuralnetworks@1.0", @@ -86,12 +75,8 @@ cc_test { "libhidlbase", "libhidlmemory", "liblog", + "libnativewindow", "libutils", ], - target: { - android: { - shared_libs: ["libnativewindow"], - }, - }, test_suites: ["general-tests"], } diff --git a/neuralnetworks/aidl/Android.bp b/neuralnetworks/aidl/Android.bp index 81252c7337..ebf4654885 100644 --- a/neuralnetworks/aidl/Android.bp +++ b/neuralnetworks/aidl/Android.bp @@ -9,7 +9,6 @@ package { aidl_interface { name: "android.hardware.neuralnetworks", - host_supported: true, vendor_available: true, srcs: [ "android/hardware/neuralnetworks/*.aidl", diff --git a/neuralnetworks/aidl/utils/Android.bp b/neuralnetworks/aidl/utils/Android.bp index 955f21f166..0ccc711ecf 100644 --- a/neuralnetworks/aidl/utils/Android.bp +++ b/neuralnetworks/aidl/utils/Android.bp @@ -41,12 +41,8 @@ cc_library_static { "android.hardware.neuralnetworks-V1-ndk_platform", "libbinder_ndk", "libhidlbase", + "libnativewindow", ], - target: { - android: { - shared_libs: ["libnativewindow"], - }, - }, } cc_test { @@ -74,21 +70,9 @@ cc_test { "libhidlbase", "libhidlmemory", "liblog", + "libnativewindow", "libutils", ], - target: { - android: { - shared_libs: ["libnativewindow"], - }, - host: { - cflags: [ - "-D__INTRODUCED_IN(x)=", - "-D__assert(a,b,c)=", - // We want all the APIs to be available on the host. - "-D__ANDROID_API__=10000", - ], - }, - }, cflags: [ /* GMOCK defines functions for printing all MOCK_DEVICE arguments and * MockDevice contains a string pointer which triggers a warning in the diff --git a/neuralnetworks/aidl/utils/src/Conversions.cpp b/neuralnetworks/aidl/utils/src/Conversions.cpp index f0871564d2..0517730849 100644 --- a/neuralnetworks/aidl/utils/src/Conversions.cpp +++ b/neuralnetworks/aidl/utils/src/Conversions.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ #include #include #include +#include #include #include @@ -46,11 +48,6 @@ #include "Utils.h" -#ifdef __ANDROID__ -#include -#include -#endif // __ANDROID__ - #define VERIFY_NON_NEGATIVE(value) \ while (UNLIKELY(value < 0)) return NN_ERROR() @@ -122,7 +119,6 @@ struct NativeHandleDeleter { using UniqueNativeHandle = std::unique_ptr; -#ifdef __ANDROID__ GeneralResult nativeHandleFromAidlHandle(const NativeHandle& handle) { auto nativeHandle = UniqueNativeHandle(dupFromAidl(handle)); if (nativeHandle.get() == nullptr) { @@ -135,7 +131,6 @@ GeneralResult nativeHandleFromAidlHandle(const NativeHandle& } return nativeHandle; } -#endif // __ANDROID__ } // anonymous namespace @@ -376,7 +371,6 @@ GeneralResult unvalidatedConvert(const aidl_hal::Memory& memory) { return createSharedMemoryFromFd(size, prot, fd, offset); } case Tag::hardwareBuffer: { -#ifdef __ANDROID__ const auto& hardwareBuffer = memory.get(); const UniqueNativeHandle handle = @@ -399,11 +393,6 @@ GeneralResult unvalidatedConvert(const aidl_hal::Memory& memory) { } return createSharedMemoryFromAHWB(ahwb, /*takeOwnership=*/true); -#else // __ANDROID__ - LOG(FATAL) << "GeneralResult unvalidatedConvert(const aidl_hal::Memory& " - "memory): Not Available on Host Build"; - return NN_ERROR() << "createFromHandle failed"; -#endif // __ANDROID__ } } return NN_ERROR() << "Unrecognized Memory::Tag: " << memory.getTag(); @@ -623,7 +612,6 @@ struct overloaded : Ts... { template overloaded(Ts...)->overloaded; -#ifdef __ANDROID__ nn::GeneralResult aidlHandleFromNativeHandle( const native_handle_t& nativeHandle) { auto handle = ::android::dupToAidl(&nativeHandle); @@ -633,7 +621,6 @@ nn::GeneralResult aidlHandleFromNativeHandle( } return handle; } -#endif // __ANDROID__ nn::GeneralResult unvalidatedConvert(const nn::Memory::Ashmem& memory) { if constexpr (std::numeric_limits::max() > std::numeric_limits::max()) { @@ -681,7 +668,6 @@ nn::GeneralResult unvalidatedConvert(const nn::Memory::Fd& memory) { } nn::GeneralResult unvalidatedConvert(const nn::Memory::HardwareBuffer& memory) { -#ifdef __ANDROID__ const native_handle_t* nativeHandle = AHardwareBuffer_getNativeHandle(memory.handle.get()); if (nativeHandle == nullptr) { return (NN_ERROR() << "unvalidatedConvert failed because AHardwareBuffer_getNativeHandle " @@ -709,12 +695,6 @@ nn::GeneralResult unvalidatedConvert(const nn::Memory::HardwareBuffer& m .handle = std::move(handle), }; return Memory::make(std::move(hardwareBuffer)); -#else // __ANDROID__ - LOG(FATAL) << "nn::GeneralResult unvalidatedConvert(const nn::Memory::HardwareBuffer& " - "memory): Not Available on Host Build"; - (void)memory; - return (NN_ERROR() << "unvalidatedConvert failed").operator nn::GeneralResult(); -#endif // __ANDROID__ } nn::GeneralResult unvalidatedConvert(const nn::Memory::Unknown& /*memory*/) { diff --git a/neuralnetworks/utils/common/Android.bp b/neuralnetworks/utils/common/Android.bp index d8f68083bd..2ed1e407ef 100644 --- a/neuralnetworks/utils/common/Android.bp +++ b/neuralnetworks/utils/common/Android.bp @@ -37,18 +37,13 @@ cc_library_static { shared_libs: [ "android.hardware.neuralnetworks-V1-ndk_platform", "libhidlbase", + "libnativewindow", "libbinder_ndk", ], - target: { - android: { - shared_libs: ["libnativewindow"], - }, - }, } cc_test { name: "neuralnetworks_utils_hal_common_test", - host_supported: true, srcs: ["test/*.cpp"], static_libs: [ "android.hardware.neuralnetworks@1.0", @@ -66,12 +61,8 @@ cc_test { "libhidlbase", "libhidlmemory", "liblog", + "libnativewindow", "libutils", ], - target: { - android: { - shared_libs: ["libnativewindow"], - }, - }, test_suites: ["general-tests"], } diff --git a/neuralnetworks/utils/common/src/CommonUtils.cpp b/neuralnetworks/utils/common/src/CommonUtils.cpp index ae02c88285..906b0cf32b 100644 --- a/neuralnetworks/utils/common/src/CommonUtils.cpp +++ b/neuralnetworks/utils/common/src/CommonUtils.cpp @@ -20,12 +20,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -34,11 +36,6 @@ #include #include -#ifdef __ANDROID__ -#include -#include -#endif // __ANDROID__ - namespace android::hardware::neuralnetworks::utils { namespace { @@ -142,7 +139,6 @@ nn::GeneralResult createHidlMemoryFrom(const nn::Memory::Fd& memory } nn::GeneralResult createHidlMemoryFrom(const nn::Memory::HardwareBuffer& memory) { -#ifdef __ANDROID__ const auto* ahwb = memory.handle.get(); AHardwareBuffer_Desc bufferDesc; AHardwareBuffer_describe(ahwb, &bufferDesc); @@ -156,12 +152,6 @@ nn::GeneralResult createHidlMemoryFrom(const nn::Memory::HardwareBu hidl_handle copiedHandle(hidlHandle); return hidl_memory(name, std::move(copiedHandle), size); -#else // __ANDROID__ - LOG(FATAL) << "nn::GeneralResult createHidlMemoryFrom(const " - "nn::Memory::HardwareBuffer& memory): Not Available on Host Build"; - (void)memory; - return (NN_ERROR() << "createHidlMemoryFrom failed").operator nn::GeneralResult(); -#endif // __ANDROID__ } nn::GeneralResult createHidlMemoryFrom(const nn::Memory::Unknown& memory) { @@ -343,11 +333,9 @@ nn::GeneralResult createHidlMemoryFromSharedMemory(const nn::Shared return std::visit([](const auto& x) { return createHidlMemoryFrom(x); }, memory->handle); } -#ifdef __ANDROID__ static uint32_t roundUpToMultiple(uint32_t value, uint32_t multiple) { return (value + multiple - 1) / multiple * multiple; } -#endif // __ANDROID__ nn::GeneralResult createSharedMemoryFromHidlMemory(const hidl_memory& memory) { CHECK_LE(memory.size(), std::numeric_limits::max()); @@ -399,7 +387,6 @@ nn::GeneralResult createSharedMemoryFromHidlMemory(const hidl_ return std::make_shared(nn::Memory{.handle = std::move(handle)}); } -#ifdef __ANDROID__ const auto size = memory.size(); const auto format = AHARDWAREBUFFER_FORMAT_BLOB; const auto usage = AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN | AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN; @@ -436,13 +423,6 @@ nn::GeneralResult createSharedMemoryFromHidlMemory(const hidl_ } return nn::createSharedMemoryFromAHWB(hardwareBuffer, /*takeOwnership=*/true); -#else // __ANDROID__ - LOG(FATAL) << "nn::GeneralResult createSharedMemoryFromHidlMemory(const " - "hidl_memory& memory): Not Available on Host Build"; - return (NN_ERROR() << "createSharedMemoryFromHidlMemory failed") - . - operator nn::GeneralResult(); -#endif // __ANDROID__ } nn::GeneralResult hidlHandleFromSharedHandle(const nn::Handle& handle) {