From a787e25542f4acdd61d558b7fa85851b94fb73da Mon Sep 17 00:00:00 2001 From: liuqi Date: Fri, 12 Apr 2019 18:23:07 +0800 Subject: [PATCH] Add input size validation for Eltwise Op. --- mace/ops/eltwise.cc | 6 ++++++ tools/sh_commands.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mace/ops/eltwise.cc b/mace/ops/eltwise.cc index 92864ae1..6803eca1 100644 --- a/mace/ops/eltwise.cc +++ b/mace/ops/eltwise.cc @@ -902,6 +902,9 @@ class EltwiseOp : public Operation { MaceStatus Run(OpContext *context) override { MACE_UNUSED(context); + MACE_CHECK(this->InputSize() < 3, + "Element-Wise does not support 3 or higher inputs," + " you could change your model to multiple Element-Wise"); const Tensor *input0 = this->Input(0); const Tensor *input1 = this->InputSize() == 2 ? this->Input(1) : nullptr; Tensor *output = this->Output(0); @@ -1192,6 +1195,9 @@ class EltwiseOp : public Operation { } } MaceStatus Run(OpContext *context) override { + MACE_CHECK(this->InputSize() < 3, + "Element-Wise does not support 3 or higher inputs," + " you could change your model to multiple Element-Wise"); const Tensor *input0 = this->Input(0); const Tensor *input1 = this->InputSize() == 2 ? this->Input(1) : nullptr; Tensor *output = this->Output(0); diff --git a/tools/sh_commands.py b/tools/sh_commands.py index 44047c26..8e25e531 100644 --- a/tools/sh_commands.py +++ b/tools/sh_commands.py @@ -787,7 +787,7 @@ def validate_model(abi, "--output_data_format=%s" % ",".join(output_data_formats), "--validation_threshold=%f" % validation_threshold, "--input_data_type=%s" % ",".join(input_data_types), - "--backend=%s" % ",".join(backend), + "--backend=%s" % backend, "--validation_outputs_data=%s" % ",".join( validation_outputs_data), "--log_file=%s" % log_file, -- GitLab