提交 8d326507 编写于 作者: C chenjiaoAngel

fix x8d build error on shared_ptr, test=ddevelop

上级 3df6aa7e
......@@ -47,8 +47,7 @@ node_map_type PoolConverter(const std::shared_ptr<lite::OpLite> pool_op,
auto ksize = op_info->GetAttr<std::vector<int>>("ksize");
auto npu_window = ge::AttrValue::LIST_INT(ksize.begin(), ksize.end());
auto padding =
*(op_info->GetAttr<std::shared_ptr<std::vector<int>>>("paddings"));
auto padding = op_info->GetAttr<std::vector<int>>("paddings");
bool pads_equal = (padding[0] == padding[1]) && (padding[2] == padding[3]);
if (!pads_equal) {
LOG(FATAL)
......
......@@ -39,8 +39,7 @@ void pool_ref(const std::shared_ptr<operators::PoolOpLite> op) {
std::vector<int> ksize = op_info->GetAttr<std::vector<int>>("ksize");
std::vector<int> strides = op_info->GetAttr<std::vector<int>>("strides");
std::vector<int> paddings =
*(op_info->GetAttr<std::shared_ptr<std::vector<int>>>("paddings"));
std::vector<int> paddings = op_info->GetAttr<std::vector<int>>("paddings");
bool exclusive = op_info->GetAttr<bool>("exclusive");
std::string pooling_type = op_info->GetAttr<std::string>("pooling_type");
bool global_pooling = op_info->GetAttr<bool>("global_pooling");
......@@ -164,9 +163,8 @@ void test_pool(int bs,
opdesc.SetAttr("global_pooling", global_pooling);
opdesc.SetAttr("exclusive", exclusive);
opdesc.SetAttr("strides", std::vector<int>({stride, stride}));
opdesc.SetAttr(
"paddings",
std::shared_ptr<std::vector<int>>({padding, padding, padding, padding}));
opdesc.SetAttr("paddings",
std::vector<int>({padding, padding, padding, padding}));
// create and convert op to NPU model, then run it on NPU
auto op = CreateOp<operators::PoolOpLite>(opdesc, &scope);
......
......@@ -89,9 +89,10 @@ TEST(pool2d, compute) {
param.output = &out;
param.global_pooling = true;
param.pooling_type = "avg";
param.paddings = std::make_shared<std::vector<int>>({0, 0, 0, 0});
std::vector<int> paddings = {0, 0, 0, 0};
param.strides = std::vector<int>{1, 1};
param.ksize = std::vector<int>{7, 7};
param.paddings = std::make_shared<std::vector<int>>(paddings);
std::unique_ptr<KernelContext> context(new KernelContext);
context->As<OpenCLContext>().InitOnce();
......
......@@ -60,7 +60,8 @@ TEST(pool2d_x86, run_test) {
param.x = &x;
param.output = &out;
param.strides = {2, 2};
param.paddings = std::make_shared<std::vector<int>>({0, 0, 0, 0});
std::vector<int> paddings = {0, 0, 0, 0};
param.paddings = std::make_shared<std::vector<int>>(paddings);
param.ksize = {2, 2};
param.pooling_type = "max";
std::unique_ptr<KernelContext> ctx(new KernelContext);
......
......@@ -38,8 +38,7 @@ node_map_type PoolConverter(const std::shared_ptr<lite::OpLite> op,
auto x_var_name = op_info->Input("X").front();
auto pooling_type = op_info->GetAttr<std::string>("pooling_type");
auto ceil_mode = op_info->GetAttr<bool>("ceil_mode");
auto paddings =
op_info->GetAttr<std::shared_ptr<std::vector<int>>>("paddings");
auto paddings = op_info->GetAttr<std::vector<int>>("paddings");
auto global_pooling = op_info->GetAttr<bool>("global_pooling");
auto ksize = op_info->GetAttr<std::vector<int>>("ksize");
auto strides = op_info->GetAttr<std::vector<int>>("strides");
......@@ -58,7 +57,7 @@ node_map_type PoolConverter(const std::shared_ptr<lite::OpLite> op,
graph_ctx->builder->CreateMaxPool2D(*input_nodes.at(x_var_name),
lite::xpu::CvtShape(ksize),
lite::xpu::CvtShape(strides),
lite::xpu::CvtShape(*paddings),
lite::xpu::CvtShape(paddings),
"NCHW",
ceil_mode));
}
......@@ -73,7 +72,7 @@ node_map_type PoolConverter(const std::shared_ptr<lite::OpLite> op,
graph_ctx->builder->CreateAvgPool2D(*input_nodes.at(x_var_name),
lite::xpu::CvtShape(ksize),
lite::xpu::CvtShape(strides),
lite::xpu::CvtShape(*paddings),
lite::xpu::CvtShape(paddings),
"NCHW",
ceil_mode,
!exclusive));
......
......@@ -38,8 +38,7 @@ void pool_ref(const std::shared_ptr<operators::PoolOpLite> op) {
std::vector<int> ksize = op_info->GetAttr<std::vector<int>>("ksize");
std::vector<int> strides = op_info->GetAttr<std::vector<int>>("strides");
std::vector<int> paddings =
*(op_info->GetAttr<std::shared_ptr<std::vector<int>>>("paddings"));
std::vector<int> paddings = op_info->GetAttr<std::vector<int>>("paddings");
bool exclusive = op_info->GetAttr<bool>("exclusive");
std::string pooling_type = op_info->GetAttr<std::string>("pooling_type");
bool global_pooling = op_info->GetAttr<bool>("global_pooling");
......@@ -163,9 +162,8 @@ void test_pool(int bs,
opdesc.SetAttr("global_pooling", global_pooling);
opdesc.SetAttr("exclusive", exclusive);
opdesc.SetAttr("strides", std::vector<int>({stride, stride}));
opdesc.SetAttr(
"paddings",
std::shared_ptr<std::vector<int>>({padding, padding, padding, padding}));
opdesc.SetAttr("paddings",
std::vector<int>({padding, padding, padding, padding}));
opdesc.SetAttr("ceil_mode", ceil_mode);
// create and convert op to XPU model, then run it on XPU
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册