Add fenced compute path to memory domain validation test. am: 2844165bf3
am: 4e82e87b1f
Change-Id: I387146070c0fb738f1701deff218d019a78c913f
This commit is contained in:
commit
e888ceafa8
3 changed files with 48 additions and 9 deletions
|
@ -78,13 +78,6 @@ enum class MemoryType { SHARED, DEVICE };
|
|||
|
||||
enum class IOType { INPUT, OUTPUT };
|
||||
|
||||
static void waitForSyncFence(int syncFd) {
|
||||
constexpr int kInfiniteTimeout = -1;
|
||||
ASSERT_GT(syncFd, 0);
|
||||
int r = sync_wait(syncFd, kInfiniteTimeout);
|
||||
ASSERT_GE(r, 0);
|
||||
}
|
||||
|
||||
struct TestConfig {
|
||||
Executor executor;
|
||||
MeasureTiming measureTiming;
|
||||
|
@ -275,6 +268,13 @@ void copyTestBuffers(const std::vector<const TestBuffer*>& buffers, uint8_t* out
|
|||
|
||||
} // namespace
|
||||
|
||||
void waitForSyncFence(int syncFd) {
|
||||
constexpr int kInfiniteTimeout = -1;
|
||||
ASSERT_GT(syncFd, 0);
|
||||
int r = sync_wait(syncFd, kInfiniteTimeout);
|
||||
ASSERT_GE(r, 0);
|
||||
}
|
||||
|
||||
Model createModel(const TestModel& testModel) {
|
||||
uint32_t constCopySize = 0;
|
||||
uint32_t constRefSize = 0;
|
||||
|
|
|
@ -77,6 +77,8 @@ enum class TestKind {
|
|||
void EvaluatePreparedModel(const sp<IDevice>& device, const sp<IPreparedModel>& preparedModel,
|
||||
const test_helper::TestModel& testModel, TestKind testKind);
|
||||
|
||||
void waitForSyncFence(int syncFd);
|
||||
|
||||
} // namespace android::hardware::neuralnetworks::V1_3::vts::functional
|
||||
|
||||
#endif // ANDROID_HARDWARE_NEURALNETWORKS_V1_3_GENERATED_TEST_HARNESS_H
|
||||
|
|
|
@ -864,6 +864,9 @@ class MemoryDomainExecutionTest
|
|||
case Executor::SYNC:
|
||||
EXPECT_EQ(executeSync(preparedModel, request), expectedStatus);
|
||||
break;
|
||||
case Executor::FENCED:
|
||||
EXPECT_EQ(executeFenced(preparedModel, request), expectedStatus);
|
||||
break;
|
||||
default:
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
|
@ -912,7 +915,38 @@ class MemoryDomainExecutionTest
|
|||
return executionStatus;
|
||||
}
|
||||
|
||||
// TODO(xusongw): Add executeFenced.
|
||||
ErrorStatus executeFenced(const sp<IPreparedModel>& preparedModel, const Request& request) {
|
||||
ErrorStatus executionStatus;
|
||||
hidl_handle syncFenceHandle;
|
||||
sp<IFencedExecutionCallback> fencedCallback;
|
||||
const auto callbackFunc = [&executionStatus, &syncFenceHandle, &fencedCallback](
|
||||
ErrorStatus error, const hidl_handle& handle,
|
||||
const sp<IFencedExecutionCallback>& callback) {
|
||||
executionStatus = error;
|
||||
syncFenceHandle = handle;
|
||||
fencedCallback = callback;
|
||||
};
|
||||
Return<void> ret = preparedModel->executeFenced(request, {}, MeasureTiming::NO, {}, {}, {},
|
||||
callbackFunc);
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
if (executionStatus != ErrorStatus::NONE) {
|
||||
EXPECT_EQ(syncFenceHandle.getNativeHandle(), nullptr);
|
||||
EXPECT_EQ(fencedCallback, nullptr);
|
||||
return executionStatus;
|
||||
}
|
||||
if (syncFenceHandle.getNativeHandle()) {
|
||||
waitForSyncFence(syncFenceHandle.getNativeHandle()->data[0]);
|
||||
}
|
||||
EXPECT_NE(fencedCallback, nullptr);
|
||||
ret = fencedCallback->getExecutionInfo(
|
||||
[&executionStatus](ErrorStatus error, Timing t, Timing) {
|
||||
executionStatus = error;
|
||||
EXPECT_EQ(UINT64_MAX, t.timeOnDevice);
|
||||
EXPECT_EQ(UINT64_MAX, t.timeInDriver);
|
||||
});
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
return executionStatus;
|
||||
}
|
||||
|
||||
const Executor kExecutor = std::get<Executor>(GetParam());
|
||||
};
|
||||
|
@ -1111,6 +1145,9 @@ TEST_P(MemoryDomainExecutionTest, SameRequestMultipleRoles) {
|
|||
}
|
||||
|
||||
TEST_P(MemoryDomainExecutionTest, InvalidDimensions) {
|
||||
// FENCED execution does not support dynamic shape.
|
||||
if (kExecutor == Executor::FENCED) return;
|
||||
|
||||
TestOperand testOperand = kTestOperand;
|
||||
testOperand.dimensions[0] = 0;
|
||||
auto preparedModel = createConvPreparedModel(testOperand);
|
||||
|
@ -1148,7 +1185,7 @@ TEST_P(MemoryDomainExecutionTest, InvalidDimensions) {
|
|||
ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
const auto kExecutorChoices = testing::Values(Executor::ASYNC, Executor::SYNC);
|
||||
const auto kExecutorChoices = testing::Values(Executor::ASYNC, Executor::SYNC, Executor::FENCED);
|
||||
|
||||
std::string printMemoryDomainExecutionTest(
|
||||
const testing::TestParamInfo<MemoryDomainExecutionTestParam>& info) {
|
||||
|
|
Loading…
Reference in a new issue