summaryrefslogtreecommitdiff
path: root/nn/common/include/CpuExecutor.h
diff options
context:
space:
mode:
Diffstat (limited to 'nn/common/include/CpuExecutor.h')
-rw-r--r--nn/common/include/CpuExecutor.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/nn/common/include/CpuExecutor.h b/nn/common/include/CpuExecutor.h
index a6bf74c95..edb233217 100644
--- a/nn/common/include/CpuExecutor.h
+++ b/nn/common/include/CpuExecutor.h
@@ -250,6 +250,14 @@ T getScalarData(const RunTimeOperandInfo& info) {
return data[0];
}
+template <typename T>
+T getScalarDataWithDefault(const RunTimeOperandInfo& info, T defaultValue) {
+ if (info.length < sizeof(T)) {
+ return defaultValue;
+ }
+ return getScalarData<T>(info);
+}
+
inline bool IsNullInput(const RunTimeOperandInfo* input) {
return input->lifetime == hal::OperandLifeTime::NO_VALUE;
}