提交 252ce0b5 编写于 作者: C cqn2219076254

add square layer

上级 d24befa0
......@@ -598,7 +598,7 @@ private:
void parseLeakyRelu (tensorflow::GraphDef& net, const tensorflow::NodeDef& layer, LayerParams& layerParams);
void parseActivation (tensorflow::GraphDef& net, const tensorflow::NodeDef& layer, LayerParams& layerParams);
void parseExpandDims (tensorflow::GraphDef& net, const tensorflow::NodeDef& layer, LayerParams& layerParams);
void parseSquare (tensorflow::GraphDef& net, const tensorflow::NodeDef& layer, LayerParams& layerParams);
void parseCustomLayer (tensorflow::GraphDef& net, const tensorflow::NodeDef& layer, LayerParams& layerParams);
};
......@@ -676,6 +676,7 @@ const TFImporter::DispatchMap TFImporter::buildDispatchMap()
dispatch["Abs"] = dispatch["Tanh"] = dispatch["Sigmoid"] = dispatch["Relu"] =
dispatch["Elu"] = dispatch["Exp"] = dispatch["Identity"] = dispatch["Relu6"] = &TFImporter::parseActivation;
dispatch["ExpandDims"] = &TFImporter::parseExpandDims;
dispatch["Square"] = &TFImporter::parseSquare;
return dispatch;
}
......@@ -1252,6 +1253,25 @@ void TFImporter::parseExpandDims(tensorflow::GraphDef& net, const tensorflow::No
}
}
// "Square"
void TFImporter::parseSquare(tensorflow::GraphDef& net, const tensorflow::NodeDef& layer, LayerParams& layerParams)
{
const std::string& name = layer.name();
const int num_inputs = layer.input_size();
CV_CheckEQ(num_inputs, 1, "");
int id;
layerParams.set("operation", "prod");
id = dstNet.addLayer(name, "Eltwise", layerParams);
layer_id[name] = id;
Pin inp = parsePin(layer.input(0));
connect(layer_id, dstNet, inp, id, 0);
connect(layer_id, dstNet, inp, id, 1);
}
// "Flatten" "Squeeze"
void TFImporter::parseFlatten(tensorflow::GraphDef& net, const tensorflow::NodeDef& layer, LayerParams& layerParams)
{
......
......@@ -670,6 +670,13 @@ TEST_P(Test_TensorFlow_layers, batch_matmul)
runTensorFlowNet("batch_matmul");
}
TEST_P(Test_TensorFlow_layers, square)
{
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
runTensorFlowNet("square");
}
TEST_P(Test_TensorFlow_layers, reshape)
{
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册