NN 1.3 HAL: ANAPIC review follow up
This CL makes the following three interface changes:
* Removes @1.3::Operand.ExtraParams, because it was the same as
@1.2::Operand.ExtraParams
* Changes int32_t token to uint32_t for IDevice::allocate and for
@1.3::Request.MemoryPool
* Renames OptionalTimePoint::nanoseconds to
OptionalTimePoint::nanosecondsSinceEpoch
This CL also makes test changes in response to the interface changes,
and fixes a minor comment issue in @1.2::types.hal and @1.3::types.hal.
Bug: 148617339
Test: mma
Test: VtsHalNeuralnetworksV1_3TargetTest
Change-Id: I95b49ab34b0b79f587dda035ede700b73dc44a38
diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal
index e867120..993a105 100644
--- a/neuralnetworks/1.2/types.hal
+++ b/neuralnetworks/1.2/types.hal
@@ -3165,7 +3165,7 @@
* * 8: An {@link OperandType::INT32} scalar, specifying the stride when
* walking through input in the ‘height’ dimension.
* * 9: An {@link OperandType::INT32} scalar, specifying the number of
- groups.
+ * groups.
* * 10: An {@link OperandType::INT32} scalar, and has to be one of the
* {@link FusedActivationFunc} values. Specifies the activation to
* invoke on the result.
diff --git a/neuralnetworks/1.3/IDevice.hal b/neuralnetworks/1.3/IDevice.hal
index 4931539..79f9c32 100644
--- a/neuralnetworks/1.3/IDevice.hal
+++ b/neuralnetworks/1.3/IDevice.hal
@@ -372,5 +372,5 @@
*/
allocate(BufferDesc desc, vec<IPreparedModel> preparedModels, vec<BufferRole> inputRoles,
vec<BufferRole> outputRoles)
- generates (ErrorStatus status, IBuffer buffer, int32_t token);
+ generates (ErrorStatus status, IBuffer buffer, uint32_t token);
};
diff --git a/neuralnetworks/1.3/types.hal b/neuralnetworks/1.3/types.hal
index ed577e4..c5dc08c 100644
--- a/neuralnetworks/1.3/types.hal
+++ b/neuralnetworks/1.3/types.hal
@@ -22,9 +22,9 @@
import @1.0::RequestArgument;
import @1.2::Model.ExtensionNameAndPrefix;
import @1.2::Model.ExtensionTypeEncoding;
+import @1.2::Operand.ExtraParams;
import @1.2::OperandType;
import @1.2::OperationType;
-import @1.2::SymmPerChannelQuantParams;
import android.hidl.safe_union@1.0::Monostate;
@@ -3253,7 +3253,7 @@
* * 8: An {@link OperandType::INT32} scalar, specifying the stride when
* walking through input in the ‘height’ dimension.
* * 9: An {@link OperandType::INT32} scalar, specifying the number of
- groups.
+ * groups.
* * 10: An {@link OperandType::INT32} scalar, and has to be one of the
* {@link FusedActivationFunc} values. Specifies the activation to
* invoke on the result.
@@ -5343,27 +5343,7 @@
/**
* Additional parameters specific to a particular operand type.
*/
- safe_union ExtraParams {
- /**
- * No additional parameters.
- */
- Monostate none;
-
- /**
- * Symmetric per-channel quantization parameters.
- *
- * Only applicable to operands of type TENSOR_QUANT8_SYMM_PER_CHANNEL.
- */
- SymmPerChannelQuantParams channelQuant;
-
- /**
- * Extension operand parameters.
- *
- * The framework treats this as an opaque data blob.
- * The format is up to individual extensions.
- */
- vec<uint8_t> extension;
- } extraParams;
+ @1.2::Operand.ExtraParams extraParams;
};
/**
@@ -5551,7 +5531,7 @@
* Specifies a driver-managed buffer. It is the token returned from IDevice::allocate,
* and is specific to the IDevice object.
*/
- int32_t token;
+ uint32_t token;
};
/**
@@ -5573,7 +5553,7 @@
* Time point of the steady clock (as from std::chrono::steady_clock)
* measured in nanoseconds.
*/
- uint64_t nanoseconds;
+ uint64_t nanosecondsSinceEpoch;
};
/**
diff --git a/neuralnetworks/1.3/types.t b/neuralnetworks/1.3/types.t
index d4351ec..3d0d02d 100644
--- a/neuralnetworks/1.3/types.t
+++ b/neuralnetworks/1.3/types.t
@@ -24,9 +24,9 @@
import @1.0::RequestArgument;
import @1.2::Model.ExtensionNameAndPrefix;
import @1.2::Model.ExtensionTypeEncoding;
+import @1.2::Operand.ExtraParams;
import @1.2::OperandType;
import @1.2::OperationType;
-import @1.2::SymmPerChannelQuantParams;
import android.hidl.safe_union@1.0::Monostate;
@@ -319,27 +319,7 @@
/**
* Additional parameters specific to a particular operand type.
*/
- safe_union ExtraParams {
- /**
- * No additional parameters.
- */
- Monostate none;
-
- /**
- * Symmetric per-channel quantization parameters.
- *
- * Only applicable to operands of type TENSOR_QUANT8_SYMM_PER_CHANNEL.
- */
- SymmPerChannelQuantParams channelQuant;
-
- /**
- * Extension operand parameters.
- *
- * The framework treats this as an opaque data blob.
- * The format is up to individual extensions.
- */
- vec<uint8_t> extension;
- } extraParams;
+ @1.2::Operand.ExtraParams extraParams;
};
/**
@@ -527,7 +507,7 @@
* Specifies a driver-managed buffer. It is the token returned from IDevice::allocate,
* and is specific to the IDevice object.
*/
- int32_t token;
+ uint32_t token;
};
/**
@@ -549,7 +529,7 @@
* Time point of the steady clock (as from std::chrono::steady_clock)
* measured in nanoseconds.
*/
- uint64_t nanoseconds;
+ uint64_t nanosecondsSinceEpoch;
};
/**
diff --git a/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp
index 8ea0b7e..82f34ff 100644
--- a/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp
+++ b/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp
@@ -122,15 +122,15 @@
// Return {IBuffer object, token} if successful.
// Return {nullptr, 0} if device memory is not supported.
template <IOType ioType>
- std::pair<sp<IBuffer>, int32_t> allocate(uint32_t index) {
- std::pair<sp<IBuffer>, int32_t> buffer;
+ std::pair<sp<IBuffer>, uint32_t> allocate(uint32_t index) {
+ std::pair<sp<IBuffer>, uint32_t> buffer;
allocateInternal<ioType>(index, &buffer);
return buffer;
}
private:
template <IOType ioType>
- void allocateInternal(uint32_t index, std::pair<sp<IBuffer>, int32_t>* result) {
+ void allocateInternal(uint32_t index, std::pair<sp<IBuffer>, uint32_t>* result) {
ASSERT_NE(result, nullptr);
// Prepare arguments.
@@ -145,14 +145,14 @@
// Allocate device memory.
ErrorStatus status;
sp<IBuffer> buffer;
- int32_t token;
- const auto ret = kDevice->allocate(
- {}, {kPreparedModel}, inputRoles, outputRoles,
- [&status, &buffer, &token](ErrorStatus error, const sp<IBuffer>& buf, int32_t tok) {
- status = error;
- buffer = buf;
- token = tok;
- });
+ uint32_t token;
+ auto cb = [&status, &buffer, &token](ErrorStatus error, const sp<IBuffer>& buf,
+ uint32_t tok) {
+ status = error;
+ buffer = buf;
+ token = tok;
+ };
+ const auto ret = kDevice->allocate({}, {kPreparedModel}, inputRoles, outputRoles, cb);
// Check allocation results.
ASSERT_TRUE(ret.isOk());
@@ -217,7 +217,7 @@
constRefSize += op.data.alignedSize();
}
- Operand::ExtraParams extraParams;
+ V1_2::Operand::ExtraParams extraParams;
if (op.type == TestOperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL) {
extraParams.channelQuant(SymmPerChannelQuantParams{
.scales = op.channelQuant.scales, .channelDim = op.channelQuant.channelDim});
@@ -317,7 +317,7 @@
// - [2+i, 2+i+o): Output device memories
DeviceMemoryAllocator allocator(device, preparedModel, testModel);
std::vector<sp<IBuffer>> buffers;
- std::vector<int32_t> tokens;
+ std::vector<uint32_t> tokens;
// Model inputs.
hidl_vec<RequestArgument> inputs(testModel.inputIndexes.size());
diff --git a/neuralnetworks/1.3/vts/functional/QualityOfServiceTests.cpp b/neuralnetworks/1.3/vts/functional/QualityOfServiceTests.cpp
index 62ffcda..2f1e05c 100644
--- a/neuralnetworks/1.3/vts/functional/QualityOfServiceTests.cpp
+++ b/neuralnetworks/1.3/vts/functional/QualityOfServiceTests.cpp
@@ -64,11 +64,11 @@
std::chrono::time_point_cast<std::chrono::nanoseconds>(currentTime);
const uint64_t nanosecondsSinceEpoch =
currentTimeInNanoseconds.time_since_epoch().count();
- deadline.nanoseconds(nanosecondsSinceEpoch);
+ deadline.nanosecondsSinceEpoch(nanosecondsSinceEpoch);
} break;
case DeadlineBoundType::UNLIMITED: {
uint64_t unlimited = std::numeric_limits<uint64_t>::max();
- deadline.nanoseconds(unlimited);
+ deadline.nanosecondsSinceEpoch(unlimited);
} break;
}
return deadline;
diff --git a/neuralnetworks/1.3/vts/functional/ValidateModel.cpp b/neuralnetworks/1.3/vts/functional/ValidateModel.cpp
index 1245432..0a35e2d 100644
--- a/neuralnetworks/1.3/vts/functional/ValidateModel.cpp
+++ b/neuralnetworks/1.3/vts/functional/ValidateModel.cpp
@@ -50,7 +50,7 @@
OptionalTimePoint deadline;
if (testDeadline) {
- deadline.nanoseconds(std::numeric_limits<uint64_t>::max());
+ deadline.nanosecondsSinceEpoch(std::numeric_limits<uint64_t>::max());
}
sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
diff --git a/neuralnetworks/1.3/vts/functional/ValidateRequest.cpp b/neuralnetworks/1.3/vts/functional/ValidateRequest.cpp
index 2fd9b64..71fe97f 100644
--- a/neuralnetworks/1.3/vts/functional/ValidateRequest.cpp
+++ b/neuralnetworks/1.3/vts/functional/ValidateRequest.cpp
@@ -61,7 +61,7 @@
OptionalTimePoint deadline;
if (testDeadline) {
- deadline.nanoseconds(std::numeric_limits<uint64_t>::max());
+ deadline.nanosecondsSinceEpoch(std::numeric_limits<uint64_t>::max());
}
// asynchronous