summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Shklyaev <slavash@google.com>2020-06-26 12:19:48 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-06-26 12:19:48 +0000
commit14f169438ee72bef00f8751bf1ec8aa96af8dff7 (patch)
treeb5c372c6e0329cfa36783d4a9f8655a924b43b4f
parent6cf4ec939ea315bb812e2ca3ce94cb13e5263d66 (diff)
parentf1c5f04cce9359f51bb74085807b1a7e7d84f167 (diff)
downloadml-14f169438ee72bef00f8751bf1ec8aa96af8dff7.tar.gz
Merge "Clarify control flow shape constraints" into rvc-dev
-rw-r--r--nn/runtime/include/NeuralNetworks.h19
-rw-r--r--nn/tools/api/README.md6
-rwxr-xr-xnn/tools/api/generate_api.py2
-rw-r--r--nn/tools/api/types.spec34
4 files changed, 44 insertions, 17 deletions
diff --git a/nn/runtime/include/NeuralNetworks.h b/nn/runtime/include/NeuralNetworks.h
index b4d304f78..2f7d3b38e 100644
--- a/nn/runtime/include/NeuralNetworks.h
+++ b/nn/runtime/include/NeuralNetworks.h
@@ -5441,12 +5441,14 @@ typedef enum {
* The inputs and outputs of the two referenced models must agree with the
* signature of this operation. That is, if the operation has (3 + n) inputs
* and m outputs, both models must have n inputs and m outputs with the same
- * types, ranks (if specified), and dimensions (if specified) as the
- * corresponding operation inputs and outputs.
+ * types, ranks (if specified), dimensions (if specified), scales,
+ * zeroPoints, and other operand parameters as the corresponding operation
+ * inputs and outputs.
*
* Inputs:
* * 0: A value of type {@link ANEURALNETWORKS_TENSOR_BOOL8} and shape [1]
* that determines which of the two referenced models to execute.
+ * The operand must have fully specified dimensions.
* * 1: A {@link ANEURALNETWORKS_MODEL} reference to the model to be
* executed if the condition is true.
* * 2: A {@link ANEURALNETWORKS_MODEL} reference to the model to be
@@ -5511,13 +5513,16 @@ typedef enum {
* Inputs:
* * 0: A {@link ANEURALNETWORKS_MODEL} reference to the condition
* model. The model must have (m + k + n) inputs with
- * the same types, ranks (if specified), and dimensions (if specified)
- * as the corresponding inputs of the WHILE operation and exactly one
- * output of {@link ANEURALNETWORKS_TENSOR_BOOL8} and shape [1].
+ * the same types, ranks (if specified), dimensions (if specified),
+ * scales, zeroPoints, and other operand parameters as the
+ * corresponding inputs of the WHILE operation and exactly one output
+ * of {@link ANEURALNETWORKS_TENSOR_BOOL8} and shape [1].
+ * The output operand must have fully specified dimensions.
* * 1: A {@link ANEURALNETWORKS_MODEL} reference to the body model.
* The model must have (m + k + n) inputs and (m + k) outputs with
- * the same types, ranks (if specified), and dimensions (if specified)
- * as the corresponding inputs and outputs of the WHILE operation.
+ * the same types, ranks (if specified), dimensions (if specified),
+ * scales, zeroPoints, and other operand parameters as the
+ * corresponding inputs and outputs of the WHILE operation.
* * (m inputs): Initial values for input-output operands.
* * (k inputs): Initial values for state-only operands.
* * (n inputs): Values for input-only operands.
diff --git a/nn/tools/api/README.md b/nn/tools/api/README.md
index e059821e8..fe4dd482f 100644
--- a/nn/tools/api/README.md
+++ b/nn/tools/api/README.md
@@ -127,8 +127,10 @@ generated output file.
#### `%define *name* *body*`
Defines a macro identified by the token *name*. The *body* is separated from
-the *name* by whitespace, and extends to the end of the line -- it may contain
-whitespace itself.
+the *name* by exactly one whitespace character, and extends to the end of the
+line -- it may contain whitespace itself. For example,
+
+ %define test this body begins and ends with a space character
Macro substitution occurs within a definition region or a section region: a
substring `%{*name*}` is replaced with the corresponding *body*. Macro
diff --git a/nn/tools/api/generate_api.py b/nn/tools/api/generate_api.py
index 3f309ed5a..00081bc2c 100755
--- a/nn/tools/api/generate_api.py
+++ b/nn/tools/api/generate_api.py
@@ -277,7 +277,7 @@ class Specification(Reader):
key = match[1]
assert not key in self.defmacro, "Duplicate definition of \"" + key + "\" on " + self.context()
tail = match[2]
- match = re.search("\s*(.*)$", tail)
+ match = re.search("\s(.*)$", tail)
if match:
self.defmacro[key] = match[1]
else:
diff --git a/nn/tools/api/types.spec b/nn/tools/api/types.spec
index 5ef9f68d4..82e4872e1 100644
--- a/nn/tools/api/types.spec
+++ b/nn/tools/api/types.spec
@@ -19,6 +19,8 @@
%define APILevel30 API level 30
%define BeforeAPILevel29For Before API level 29, for
%define or_1.2 or {@link ANEURALNETWORKS_%{1}}
+%define NDK_if_specified (if specified)
+%define otherOperandParameters other operand parameters
%define-lines AVAIL27
*
* Available since API level 27.
@@ -62,6 +64,8 @@
%define MODEL_or_SUBGRAPH SUBGRAPH
%define APILevel29 HAL version 1.2
%define APILevel30 HAL version 1.3
+%define NDK_if_specified
+%define otherOperandParameters extraParams
%define-lines AVAIL27
%/define-lines
%define-lines AVAIL27Short
@@ -6176,12 +6180,17 @@
* The inputs and outputs of the two referenced %{model_or_subgraph}s must agree with the
* signature of this operation. That is, if the operation has (3 + n) inputs
* and m outputs, both %{model_or_subgraph}s must have n inputs and m outputs with the same
- * types, ranks (if specified), and dimensions (if specified) as the
- * corresponding operation inputs and outputs.
+ * types, ranks%{NDK_if_specified}, dimensions%{NDK_if_specified}, scales,
+ * zeroPoints, and %{otherOperandParameters} as the corresponding operation
+ * inputs and outputs.
+%kind hal*
+ * All of the operands mentioned must have fully specified dimensions.
+%/kind
*
* Inputs:
* * 0: A value of type {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} and shape [1]
* that determines which of the two referenced %{model_or_subgraph}s to execute.
+ * The operand must have fully specified dimensions.
* * 1: A {@link %{OperandTypeLinkPfx}%{MODEL_or_SUBGRAPH}} reference to the %{model_or_subgraph} to be
* executed if the condition is true.
* * 2: A {@link %{OperandTypeLinkPfx}%{MODEL_or_SUBGRAPH}} reference to the %{model_or_subgraph} to be
@@ -6247,13 +6256,24 @@
* Inputs:
* * 0: A {@link %{OperandTypeLinkPfx}%{MODEL_or_SUBGRAPH}} reference to the condition
* %{model_or_subgraph}. The %{model_or_subgraph} must have (m + k + n) inputs with
- * the same types, ranks (if specified), and dimensions (if specified)
- * as the corresponding inputs of the WHILE operation and exactly one
- * output of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} and shape [1].
+ * the same types, ranks%{NDK_if_specified}, dimensions%{NDK_if_specified},
+ * scales, zeroPoints, and %{otherOperandParameters} as the
+ * corresponding inputs of the WHILE operation and exactly one output
+ * of {@link %{OperandTypeLinkPfx}TENSOR_BOOL8} and shape [1].
+%kind ndk
+ * The output operand must have fully specified dimensions.
+%/kind
+%kind hal*
+ * All of the operands mentioned must have fully specified dimensions.
+%/kind
* * 1: A {@link %{OperandTypeLinkPfx}%{MODEL_or_SUBGRAPH}} reference to the body %{model_or_subgraph}.
* The %{model_or_subgraph} must have (m + k + n) inputs and (m + k) outputs with
- * the same types, ranks (if specified), and dimensions (if specified)
- * as the corresponding inputs and outputs of the WHILE operation.
+ * the same types, ranks%{NDK_if_specified}, dimensions%{NDK_if_specified},
+ * scales, zeroPoints, and %{otherOperandParameters} as the
+ * corresponding inputs and outputs of the WHILE operation.
+%kind hal*
+ * All of the operands mentioned must have fully specified dimensions.
+%/kind
* * (m inputs): Initial values for input-output operands.
* * (k inputs): Initial values for state-only operands.
* * (n inputs): Values for input-only operands.