summaryrefslogtreecommitdiff
path: root/nn
diff options
context:
space:
mode:
authorXusong Wang <xusongw@google.com>2020-05-15 10:48:33 -0700
committerXusong Wang <xusongw@google.com>2020-06-02 16:48:13 -0700
commit9ec5e40a1dbc58afb52e43e51d9e9dcecc5428ff (patch)
tree17b7471fbbebe78df572ce3b862c97ce889e0068 /nn
parentcc7ab07f7d1772b43d5a20afff8f95a257253b79 (diff)
downloadml-9ec5e40a1dbc58afb52e43e51d9e9dcecc5428ff.tar.gz
Fix FULLY_CONNECTED issue with unknown num_units.
Fixes: 156748888 Test: NNT_static Test: 1.3 VTS with ag/11509996 Change-Id: Ib3b191ccefdfd0d03f8c69772976ef0f2421a9d7 Merged-In: Ib3b191ccefdfd0d03f8c69772976ef0f2421a9d7 (cherry picked from commit f0af901e251b46938ceca80658b5cefc67fc7b6d)
Diffstat (limited to 'nn')
-rw-r--r--nn/common/operations/FullyConnected.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/nn/common/operations/FullyConnected.cpp b/nn/common/operations/FullyConnected.cpp
index 71808c0b7..9bdd0bab2 100644
--- a/nn/common/operations/FullyConnected.cpp
+++ b/nn/common/operations/FullyConnected.cpp
@@ -200,11 +200,14 @@ bool validateShapes(const Shape& input, const Shape& weights, const Shape& bias,
uint32_t input_n_elements = getNumberOfElements(input);
uint32_t num_units = getSizeOfDimension(weights, 0);
uint32_t input_size = getSizeOfDimension(weights, 1);
+ uint32_t bias_len = getSizeOfDimension(bias, 0);
uint32_t batch_size = input_size == 0 ? 0 : input_n_elements / input_size;
if (batch_size != 0) {
NN_RET_CHECK_EQ(input_size * batch_size, input_n_elements);
}
- NN_RET_CHECK_EQ(getSizeOfDimension(bias, 0), num_units);
+ if (num_units != 0 && bias_len != 0) {
+ NN_RET_CHECK_EQ(bias_len, num_units);
+ }
if (output != nullptr) {
// Only batch_size can be 0.
NN_RET_CHECK_GT(num_units, 0);