From c331067aac17caf67c5941c56862fed514ca5a9f Mon Sep 17 00:00:00 2001 From: Michael Butler Date: Mon, 1 Nov 2021 18:19:57 -0700 Subject: [PATCH] Move Aidl utility code to aidl/utils -- hal 2/2 This change is part of an effort to remove HAL types from libneuralnetworks_common*. This change: * Updates the header guard names for the new directory * Removes the "Aidl" prefix from the files * Adds temporary "Aidl" header files under include/ that redirect to their corresponding files in include/nnapi/hal/aidl/ * Changes references of libneuralnetworks_common_hidl to libneuralnetworks_common Bug: 191442336 Test: mma Change-Id: Icbcc04e0a49a9adf8d8826fd5735028ea26de0ca --- neuralnetworks/1.0/utils/Android.bp | 2 +- neuralnetworks/1.0/vts/functional/Android.bp | 4 ++-- neuralnetworks/1.1/utils/Android.bp | 2 +- neuralnetworks/1.1/vts/functional/Android.bp | 2 +- neuralnetworks/1.2/utils/Android.bp | 2 +- neuralnetworks/1.2/vts/functional/Android.bp | 2 +- neuralnetworks/1.3/utils/Android.bp | 2 +- neuralnetworks/1.3/vts/functional/Android.bp | 2 +- .../aidl/utils/include/AidlBufferTracker.h | 17 +++++++++++++++++ .../aidl/utils/include/AidlHalInterfaces.h | 17 +++++++++++++++++ .../aidl/utils/include/AidlHalUtils.h | 17 +++++++++++++++++ .../aidl/utils/include/AidlValidateHal.h | 17 +++++++++++++++++ .../{AidlBufferTracker.h => BufferTracker.h} | 10 +++++----- .../{AidlHalInterfaces.h => HalInterfaces.h} | 6 +++--- .../hal/aidl/{AidlHalUtils.h => HalUtils.h} | 8 ++++---- .../aidl/{AidlValidateHal.h => ValidateHal.h} | 13 +++++++------ neuralnetworks/utils/common/Android.bp | 2 +- 17 files changed, 97 insertions(+), 28 deletions(-) create mode 100644 neuralnetworks/aidl/utils/include/AidlBufferTracker.h create mode 100644 neuralnetworks/aidl/utils/include/AidlHalInterfaces.h create mode 100644 neuralnetworks/aidl/utils/include/AidlHalUtils.h create mode 100644 neuralnetworks/aidl/utils/include/AidlValidateHal.h rename neuralnetworks/aidl/utils/include/nnapi/hal/aidl/{AidlBufferTracker.h => BufferTracker.h} (93%) rename neuralnetworks/aidl/utils/include/nnapi/hal/aidl/{AidlHalInterfaces.h => HalInterfaces.h} (93%) rename neuralnetworks/aidl/utils/include/nnapi/hal/aidl/{AidlHalUtils.h => HalUtils.h} (86%) rename neuralnetworks/aidl/utils/include/nnapi/hal/aidl/{AidlValidateHal.h => ValidateHal.h} (80%) diff --git a/neuralnetworks/1.0/utils/Android.bp b/neuralnetworks/1.0/utils/Android.bp index 4e35a26c8f..31cdded56e 100644 --- a/neuralnetworks/1.0/utils/Android.bp +++ b/neuralnetworks/1.0/utils/Android.bp @@ -55,7 +55,7 @@ cc_test { static_libs: [ "android.hardware.neuralnetworks@1.0", "libgmock", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "neuralnetworks_types", "neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_1_0", diff --git a/neuralnetworks/1.0/vts/functional/Android.bp b/neuralnetworks/1.0/vts/functional/Android.bp index ae9ff0a795..29b31d254e 100644 --- a/neuralnetworks/1.0/vts/functional/Android.bp +++ b/neuralnetworks/1.0/vts/functional/Android.bp @@ -50,7 +50,7 @@ cc_library_static { "libgmock", "libhidlmemory", "libneuralnetworks_generated_test_harness", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", ], header_libs: [ "libneuralnetworks_headers", @@ -81,7 +81,7 @@ cc_test { "libgmock", "libhidlmemory", "libneuralnetworks_generated_test_harness", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", ], whole_static_libs: [ "neuralnetworks_generated_V1_0_example", diff --git a/neuralnetworks/1.1/utils/Android.bp b/neuralnetworks/1.1/utils/Android.bp index 478a7426d2..737ff58159 100644 --- a/neuralnetworks/1.1/utils/Android.bp +++ b/neuralnetworks/1.1/utils/Android.bp @@ -52,7 +52,7 @@ cc_test { "android.hardware.neuralnetworks@1.0", "android.hardware.neuralnetworks@1.1", "libgmock", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "neuralnetworks_types", "neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_1_0", diff --git a/neuralnetworks/1.1/vts/functional/Android.bp b/neuralnetworks/1.1/vts/functional/Android.bp index 4c577882a7..e9d4b76221 100644 --- a/neuralnetworks/1.1/vts/functional/Android.bp +++ b/neuralnetworks/1.1/vts/functional/Android.bp @@ -48,7 +48,7 @@ cc_test { "libgmock", "libhidlmemory", "libneuralnetworks_generated_test_harness", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", ], whole_static_libs: [ "neuralnetworks_generated_V1_0_example", diff --git a/neuralnetworks/1.2/utils/Android.bp b/neuralnetworks/1.2/utils/Android.bp index 2a86a0011c..4eefb0f7dc 100644 --- a/neuralnetworks/1.2/utils/Android.bp +++ b/neuralnetworks/1.2/utils/Android.bp @@ -71,7 +71,7 @@ cc_test { "android.hardware.neuralnetworks@1.1", "android.hardware.neuralnetworks@1.2", "libgmock", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "neuralnetworks_types", "neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_1_0", diff --git a/neuralnetworks/1.2/vts/functional/Android.bp b/neuralnetworks/1.2/vts/functional/Android.bp index 15a5d2fcc8..52d51e2ce9 100644 --- a/neuralnetworks/1.2/vts/functional/Android.bp +++ b/neuralnetworks/1.2/vts/functional/Android.bp @@ -71,7 +71,7 @@ cc_test { "libgmock", "libhidlmemory", "libneuralnetworks_generated_test_harness", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", ], whole_static_libs: [ "neuralnetworks_generated_V1_0_example", diff --git a/neuralnetworks/1.3/utils/Android.bp b/neuralnetworks/1.3/utils/Android.bp index 8ae509f4d0..7acb4fcb30 100644 --- a/neuralnetworks/1.3/utils/Android.bp +++ b/neuralnetworks/1.3/utils/Android.bp @@ -69,7 +69,7 @@ cc_test { "android.hardware.neuralnetworks@1.2", "android.hardware.neuralnetworks@1.3", "libgmock", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "neuralnetworks_types", "neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_1_0", diff --git a/neuralnetworks/1.3/vts/functional/Android.bp b/neuralnetworks/1.3/vts/functional/Android.bp index ca59cc20ec..89517602d2 100644 --- a/neuralnetworks/1.3/vts/functional/Android.bp +++ b/neuralnetworks/1.3/vts/functional/Android.bp @@ -75,7 +75,7 @@ cc_test { "libgmock", "libhidlmemory", "libneuralnetworks_generated_test_harness", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "libsync", ], whole_static_libs: [ diff --git a/neuralnetworks/aidl/utils/include/AidlBufferTracker.h b/neuralnetworks/aidl/utils/include/AidlBufferTracker.h new file mode 100644 index 0000000000..4421876336 --- /dev/null +++ b/neuralnetworks/aidl/utils/include/AidlBufferTracker.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "nnapi/hal/aidl/BufferTracker.h" diff --git a/neuralnetworks/aidl/utils/include/AidlHalInterfaces.h b/neuralnetworks/aidl/utils/include/AidlHalInterfaces.h new file mode 100644 index 0000000000..37779694e9 --- /dev/null +++ b/neuralnetworks/aidl/utils/include/AidlHalInterfaces.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "nnapi/hal/aidl/HalInterfaces.h" diff --git a/neuralnetworks/aidl/utils/include/AidlHalUtils.h b/neuralnetworks/aidl/utils/include/AidlHalUtils.h new file mode 100644 index 0000000000..98bfbad3cc --- /dev/null +++ b/neuralnetworks/aidl/utils/include/AidlHalUtils.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "nnapi/hal/aidl/HalUtils.h" diff --git a/neuralnetworks/aidl/utils/include/AidlValidateHal.h b/neuralnetworks/aidl/utils/include/AidlValidateHal.h new file mode 100644 index 0000000000..5aaa74d01d --- /dev/null +++ b/neuralnetworks/aidl/utils/include/AidlValidateHal.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "nnapi/hal/aidl/ValidateHal.h" diff --git a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlBufferTracker.h b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/BufferTracker.h similarity index 93% rename from neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlBufferTracker.h rename to neuralnetworks/aidl/utils/include/nnapi/hal/aidl/BufferTracker.h index 970606c8dd..18d01e22e9 100644 --- a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlBufferTracker.h +++ b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/BufferTracker.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_BUFFER_TRACKER_H -#define ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_BUFFER_TRACKER_H +#ifndef ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_BUFFER_TRACKER_H +#define ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_BUFFER_TRACKER_H #include #include @@ -28,8 +28,8 @@ #include #include -#include "AidlHalInterfaces.h" -#include "AidlValidateHal.h" +#include "nnapi/hal/aidl/HalInterfaces.h" +#include "nnapi/hal/aidl/ValidateHal.h" namespace android::nn { @@ -116,4 +116,4 @@ class AidlBufferTracker : public std::enable_shared_from_this } // namespace android::nn -#endif // ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_BUFFER_TRACKER_H +#endif // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_BUFFER_TRACKER_H diff --git a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlHalInterfaces.h b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/HalInterfaces.h similarity index 93% rename from neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlHalInterfaces.h rename to neuralnetworks/aidl/utils/include/nnapi/hal/aidl/HalInterfaces.h index 28379bbb2d..3fb443c388 100644 --- a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlHalInterfaces.h +++ b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/HalInterfaces.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_HAL_INTERFACES_H -#define ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_HAL_INTERFACES_H +#ifndef ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_HAL_INTERFACES_H +#define ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_HAL_INTERFACES_H #include #include @@ -69,4 +69,4 @@ inline constexpr aidl_hal::Priority kDefaultPriorityAidl = aidl_hal::Priority::M } // namespace android::nn -#endif // ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_HAL_INTERFACES_H +#endif // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_HAL_INTERFACES_H diff --git a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlHalUtils.h b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/HalUtils.h similarity index 86% rename from neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlHalUtils.h rename to neuralnetworks/aidl/utils/include/nnapi/hal/aidl/HalUtils.h index af2b387c15..89552bcc38 100644 --- a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlHalUtils.h +++ b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/HalUtils.h @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_HAL_UTILS_H -#define ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_HAL_UTILS_H +#ifndef ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_HAL_UTILS_H +#define ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_HAL_UTILS_H #include -#include "AidlHalInterfaces.h" +#include "nnapi/hal/aidl/HalInterfaces.h" namespace android { namespace nn { @@ -49,4 +49,4 @@ bool isNonExtensionScalar(aidl_hal::OperandType type); } // namespace nn } // namespace android -#endif // ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_HAL_UTILS_H +#endif // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_HAL_UTILS_H diff --git a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlValidateHal.h b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/ValidateHal.h similarity index 80% rename from neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlValidateHal.h rename to neuralnetworks/aidl/utils/include/nnapi/hal/aidl/ValidateHal.h index 03546315c8..62aba31bc3 100644 --- a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/AidlValidateHal.h +++ b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/ValidateHal.h @@ -14,17 +14,18 @@ * limitations under the License. */ -#ifndef ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_VALIDATE_HAL_H -#define ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_VALIDATE_HAL_H +#ifndef ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_VALIDATE_HAL_H +#define ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_VALIDATE_HAL_H + +#include "nnapi/hal/aidl/HalInterfaces.h" #include #include #include #include -#include "AidlHalInterfaces.h" -#include "nnapi/TypeUtils.h" -#include "nnapi/Validation.h" +#include +#include namespace android { namespace nn { @@ -43,4 +44,4 @@ bool validateMemoryDesc( } // namespace nn } // namespace android -#endif // ANDROID_FRAMEWORKS_ML_NN_COMMON_AIDL_VALIDATE_HAL_H +#endif // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_VALIDATE_HAL_H diff --git a/neuralnetworks/utils/common/Android.bp b/neuralnetworks/utils/common/Android.bp index c01460e81b..39927a363c 100644 --- a/neuralnetworks/utils/common/Android.bp +++ b/neuralnetworks/utils/common/Android.bp @@ -39,7 +39,7 @@ cc_test { srcs: ["test/*.cpp"], static_libs: [ "libgmock", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "neuralnetworks_types", "neuralnetworks_utils_hal_common", ],