From: Alexander Efimov/AI Tools Lab/./Samsung Electronics Date: Mon, 7 Oct 2019 01:55:20 +0000 (+0300) Subject: Fix validate check in Conv2d (#7937) X-Git-Tag: submit/tizen/20191205.083104~937 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3af92011b295ce6e45460895b5f1771219ab4cc1;p=platform%2Fcore%2Fml%2Fnnfw.git Fix validate check in Conv2d (#7937) Do not accept conv2d operation with non one dilations Signed-off-by: Efimov Alexander --- diff --git a/compiler/moco-tf/src/Op/Conv2D.cpp b/compiler/moco-tf/src/Op/Conv2D.cpp index 7e011a7..323cf71 100644 --- a/compiler/moco-tf/src/Op/Conv2D.cpp +++ b/compiler/moco-tf/src/Op/Conv2D.cpp @@ -37,6 +37,7 @@ #include #include +#include namespace { @@ -131,7 +132,16 @@ bool Conv2DGraphBuilderBase::validate(const tensorflow::NodeDef &node) const // note: even though "data_format" is not entered when a model is written, // TF seems to generate "data_format" field into a pb file - return plier::tf::has_attrs(node, {"T", "data_format", "dilations", "padding", "strides"}); + bool has_mandatory_attrs = plier::tf::has_attrs(node, {"T", "data_format", "padding", "strides"}); + // dilation attribute is not fully supported + bool supported_dilations = true; + if (plier::tf::has_attr(node, "dilations")) + { + auto dilation = plier::tf::get_list_attr(node, "dilations").i(); + supported_dilations = + std::all_of(dilation.begin(), dilation.end(), [](std::int64_t dil) { return dil == 1; }); + } + return has_mandatory_attrs && supported_dilations; } void Conv2DGraphBuilder::build(const tensorflow::NodeDef &node, GraphBuilderContext *context) const