blob: b64dc2f61bbe6fc9eb791f1bc8086525b175ea6e [file] [log] [blame]
Colin Crossb098d212019-10-10 22:58:36 +00001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "neuralnetworks_hidl_hal_test"
18
19#include "VtsHalNeuralnetworks.h"
20
Colin Cross552c7a62019-10-10 22:58:41 +000021namespace android::hardware::neuralnetworks::V1_3::vts::functional {
Colin Crossb098d212019-10-10 22:58:36 +000022
23using V1_0::DeviceStatus;
24using V1_0::ErrorStatus;
25using V1_0::PerformanceInfo;
Colin Cross552c7a62019-10-10 22:58:41 +000026using V1_2::Constant;
27using V1_2::DeviceType;
28using V1_2::Extension;
Colin Crossb098d212019-10-10 22:58:36 +000029
30// create device test
31TEST_P(NeuralnetworksHidlTest, CreateDevice) {}
32
33// status test
34TEST_P(NeuralnetworksHidlTest, StatusTest) {
35 Return<DeviceStatus> status = kDevice->getStatus();
36 ASSERT_TRUE(status.isOk());
37 EXPECT_EQ(DeviceStatus::AVAILABLE, static_cast<DeviceStatus>(status));
38}
39
40// initialization
41TEST_P(NeuralnetworksHidlTest, GetCapabilitiesTest) {
42 using OperandPerformance = Capabilities::OperandPerformance;
Colin Cross552c7a62019-10-10 22:58:41 +000043 Return<void> ret = kDevice->getCapabilities_1_3([](ErrorStatus status,
Colin Crossb098d212019-10-10 22:58:36 +000044 const Capabilities& capabilities) {
45 EXPECT_EQ(ErrorStatus::NONE, status);
46
47 auto isPositive = [](const PerformanceInfo& perf) {
48 return perf.execTime > 0.0f && perf.powerUsage > 0.0f;
49 };
50
51 EXPECT_TRUE(isPositive(capabilities.relaxedFloat32toFloat16PerformanceScalar));
52 EXPECT_TRUE(isPositive(capabilities.relaxedFloat32toFloat16PerformanceTensor));
53 const auto& opPerf = capabilities.operandPerformance;
54 EXPECT_TRUE(std::all_of(
55 opPerf.begin(), opPerf.end(),
56 [isPositive](const OperandPerformance& a) { return isPositive(a.info); }));
57 EXPECT_TRUE(std::is_sorted(opPerf.begin(), opPerf.end(),
58 [](const OperandPerformance& a, const OperandPerformance& b) {
59 return a.type < b.type;
60 }));
61 });
62 EXPECT_TRUE(ret.isOk());
63}
Colin Cross552c7a62019-10-10 22:58:41 +000064} // namespace android::hardware::neuralnetworks::V1_3::vts::functional