Skip to content

Commit 5dc3f81

Browse files
committed
refine anakin op converter
1 parent a874e9d commit 5dc3f81

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

paddle/fluid/inference/anakin/convert/batch_norm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "paddle/fluid/inference/anakin/convert/batch_norm.h"
1616
#include <math.h>
17+
#include <algorithm>
1718
#include <map>
1819
#include <string>
1920
#include <vector>
@@ -41,7 +42,6 @@ void BatchNormOpConverter::operator()(const framework::proto::OpDesc &op,
4142

4243
auto output = op_desc.Output("Y").front();
4344
auto op_name = op_desc.Type() + ":" + op_desc.Output("Y").front();
44-
bool is_test = boost::get<bool>(op_desc.GetAttr("is_test"));
4545
auto epsilon = boost::get<float>(op_desc.GetAttr("epsilon"));
4646

4747
auto bn_op_name = op_name + ":bn";

paddle/fluid/inference/anakin/convert/flatten.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ void FlattenOpConverter::operator()(const framework::proto::OpDesc &op,
4848
} // namespace inference
4949
} // namespace paddle
5050

51-
REGISTER_ANAKIN_OP_CONVERTER(flatten2, FlattenOpConverter);
51+
REGISTER_ANAKIN_OP_CONVERTER(flatten, FlattenOpConverter);

paddle/fluid/inference/anakin/convert/op_converter.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ class AnakinOpConverter {
4747
std::string op_type = op_desc.Type();
4848
AnakinOpConverter *it = nullptr;
4949

50-
std::cout << op_type << std::endl;
50+
if (op_type == "reshape2") op_type = "reshape";
51+
if (op_type == "transpose2") op_type = "transpose";
52+
if (op_type == "flatten2") op_type = "flatten";
53+
5154
if (!it) {
5255
it = Registry<AnakinOpConverter>::Global().Lookup(op_type);
5356
}

paddle/fluid/inference/anakin/convert/reshape.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ void ReshapeOpConverter::operator()(const framework::proto::OpDesc &op,
4949
} // namespace inference
5050
} // namespace paddle
5151

52-
REGISTER_ANAKIN_OP_CONVERTER(reshape2, ReshapeOpConverter);
52+
REGISTER_ANAKIN_OP_CONVERTER(reshape, ReshapeOpConverter);

paddle/fluid/inference/anakin/convert/transpose.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ void TransposeOpConverter::operator()(const framework::proto::OpDesc &op,
5252
} // namespace inference
5353
} // namespace paddle
5454

55-
REGISTER_ANAKIN_OP_CONVERTER(transpose2, TransposeOpConverter);
55+
REGISTER_ANAKIN_OP_CONVERTER(transpose, TransposeOpConverter);

paddle/fluid/inference/api/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@ if (WITH_ANAKIN AND WITH_MKL) # only needed in CI
6464
anakin_target(inference_anakin_api)
6565
anakin_target(inference_anakin_api_shared)
6666
endif()
67+
if (WITH_ANAKIN_SUBGRAPH)
68+
inference_analysis_test(test_anakin_model SRCS mobilenet_test.cc EXTRA_DEPS paddle_fluid)
69+
inference_analysis_test(anakin_conv_model SRCS conv_anakin_test.cc EXTRA_DEPS paddle_fluid)
70+
inference_analysis_test(life_feature_test SRCS life_feature_test.cc EXTRA_DEPS paddle_fluid)
71+
endif()

paddle/fluid/inference/api/analysis_predictor.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,9 @@ USE_ANAKIN_CONVERTER(tanh);
780780
USE_ANAKIN_CONVERTER(pool2d);
781781
USE_ANAKIN_CONVERTER(elementwise_add);
782782
USE_ANAKIN_CONVERTER(batch_norm);
783-
USE_ANAKIN_CONVERTER(flatten2);
784-
USE_ANAKIN_CONVERTER(reshape2);
785-
USE_ANAKIN_CONVERTER(transpose2);
783+
USE_ANAKIN_CONVERTER(flatten);
784+
USE_ANAKIN_CONVERTER(reshape);
785+
USE_ANAKIN_CONVERTER(transpose);
786786
USE_ANAKIN_CONVERTER(softmax);
787787

788788
USE_ANAKIN_CONVERTER(detection_out);

0 commit comments

Comments
 (0)