Merge pull request #17386 from l-bat:tf_clamp_subgraph

* Added ClipByValue subgraph

* Return const nodes
pull/17419/head
Liubov Batanina 5 years ago committed by GitHub
parent 9e09828cc3
commit ba3cf47600
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      modules/dnn/src/tensorflow/tf_graph_simplifier.cpp
  2. 5
      modules/dnn/test/test_tf_importer.cpp

@ -725,6 +725,21 @@ private:
bool negativeScales;
};
class ClipByValueSubgraph : public TFSubgraph
{
public:
ClipByValueSubgraph()
{
int input = addNodeToMatch("");
int maxValue = addNodeToMatch("Const");
int minimum = addNodeToMatch("Minimum", input, maxValue);
int minValue = addNodeToMatch("Const");
addNodeToMatch("Maximum", minimum, minValue);
setFusedNode("ClipByValue", input, minValue, maxValue);
}
};
void simplifySubgraphs(tensorflow::GraphDef& net)
{
std::vector<Ptr<Subgraph> > subgraphs;
@ -749,6 +764,7 @@ void simplifySubgraphs(tensorflow::GraphDef& net)
subgraphs.push_back(Ptr<Subgraph>(new PReLUSubgraph(false)));
subgraphs.push_back(Ptr<Subgraph>(new FlattenProdSubgraph()));
subgraphs.push_back(Ptr<Subgraph>(new ResizeBilinearSubgraphDown()));
subgraphs.push_back(Ptr<Subgraph>(new ClipByValueSubgraph()));
for (int i = 0; i < net.node_size(); ++i)
{

@ -977,6 +977,11 @@ TEST_P(Test_TensorFlow_layers, tf2_dense)
runTensorFlowNet("tf2_dense");
}
TEST_P(Test_TensorFlow_layers, clip_by_value)
{
runTensorFlowNet("clip_by_value");
}
TEST_P(Test_TensorFlow_layers, tf2_prelu)
{
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)

Loading…
Cancel
Save