diff --git a/paddle/fluid/inference/anakin/convert/conv2d.cc b/paddle/fluid/inference/anakin/convert/conv2d.cc index 26f78efa61cbd984978f830277340d53c3895d67..7904d407c36b4c66f675c5dd9fd62f8fe91e1908 100644 --- a/paddle/fluid/inference/anakin/convert/conv2d.cc +++ b/paddle/fluid/inference/anakin/convert/conv2d.cc @@ -41,7 +41,7 @@ void Conv2dOpConverter::operator()( auto *filter_v = scope.FindVar(op_desc.Input("Filter").front()); PADDLE_ENFORCE_NOT_NULL(filter_v); auto weight_tensor = tensor_from_var(*filter_v, platform::CPUPlace()); - auto weight_shape = framework::vectorize2int(weight_tensor->dims()); + auto weight_shape = framework::vectorize(weight_tensor->dims()); PADDLE_ENFORCE_EQ(weight_tensor->dims().size(), 4UL); diff --git a/paddle/fluid/inference/anakin/convert/conv2d_fusion.cc b/paddle/fluid/inference/anakin/convert/conv2d_fusion.cc index f2e6003aa6849fce57111fadf88fb27bcc95f42e..4d7a502dee341b44236749813bb982be8a003af7 100644 --- a/paddle/fluid/inference/anakin/convert/conv2d_fusion.cc +++ b/paddle/fluid/inference/anakin/convert/conv2d_fusion.cc @@ -43,7 +43,7 @@ void Conv2dFusionOpConverter::operator()( PADDLE_ENFORCE_NOT_NULL(filter_v); auto weight_tensor = tensor_from_var(*filter_v, platform::CPUPlace()); - auto weight_shape = framework::vectorize2int(weight_tensor->dims()); + auto weight_shape = framework::vectorize(weight_tensor->dims()); auto *b_v = scope.FindVar(op_desc.Input("Bias").front()); PADDLE_ENFORCE_NOT_NULL(b_v); @@ -99,7 +99,7 @@ void Conv2dFusionOpConverter::operator()( this->engine_->AddTensorScale(input_name, in_scale / int8_range); } else { auto weight_tensor = tensor_from_var(*filter_v, platform::CPUPlace()); - auto weight_shape = framework::vectorize2int(weight_tensor->dims()); + auto weight_shape = framework::vectorize(weight_tensor->dims()); auto *weight1 = pblock_from_tensor( *weight_tensor, weight_shape, this->engine_); this->engine_->AddOpAttr(op_name, "weight_1", *weight1); diff --git a/paddle/fluid/inference/anakin/convert/fc.cc b/paddle/fluid/inference/anakin/convert/fc.cc index b64d0b84fd45fe041c18721968fbc6ce8a794af5..265d318aaee20d14350da3fb32a02ea66373c7fc 100644 --- a/paddle/fluid/inference/anakin/convert/fc.cc +++ b/paddle/fluid/inference/anakin/convert/fc.cc @@ -43,7 +43,7 @@ void FcBaseOpConverter::operator()( auto *y_v = scope.FindVar(op_desc.Input(w_name).front()); PADDLE_ENFORCE_NOT_NULL(y_v); auto weight_tensor = tensor_from_var(*y_v, platform::CPUPlace()); - auto weight_shape = framework::vectorize2int(weight_tensor->dims()); + auto weight_shape = framework::vectorize(weight_tensor->dims()); int out_dim = weight_shape[1]; const int w_m = weight_shape[0]; diff --git a/paddle/fluid/inference/anakin/convert/helper.h b/paddle/fluid/inference/anakin/convert/helper.h index 7b0fb211dcd8aa03fdad91d7cacfa11d2ceaae43..6ba8fd6ceb5e7850263da224e07e08d88ec2992b 100644 --- a/paddle/fluid/inference/anakin/convert/helper.h +++ b/paddle/fluid/inference/anakin/convert/helper.h @@ -86,7 +86,7 @@ template PBlock* pblock_from_var(const framework::Variable& var, AnakinEngine* engine) { auto tensor = tensor_from_var(var, platform::CPUPlace()); - auto shape = framework::vectorize2int(tensor->dims()); + auto shape = framework::vectorize(tensor->dims()); return pblock_from_tensor(*tensor, shape, engine); } diff --git a/paddle/fluid/inference/anakin/convert/ut_helper.h b/paddle/fluid/inference/anakin/convert/ut_helper.h index 92441f2560f3260c892f14c72d07d4f5bb2e6e7e..f2b56a2569f584ea8751c4fedcf28b02775147f9 100644 --- a/paddle/fluid/inference/anakin/convert/ut_helper.h +++ b/paddle/fluid/inference/anakin/convert/ut_helper.h @@ -136,7 +136,7 @@ class AnakinConvertValidation { if (parameters_.count(input)) continue; auto& t = inference::analysis::GetFromScope(*scope_, input); - auto t_shape = framework::vectorize2int(t.dims()); + auto t_shape = framework::vectorize(t.dims()); while (t_shape.size() < 4) { t_shape.push_back(1); } diff --git a/paddle/fluid/inference/anakin/engine.cc b/paddle/fluid/inference/anakin/engine.cc index 13f16c4c8982ef491234fbc36b4e418b419a3dc9..d57952db0d36051a219391868f19a55079b8d7bf 100644 --- a/paddle/fluid/inference/anakin/engine.cc +++ b/paddle/fluid/inference/anakin/engine.cc @@ -86,7 +86,7 @@ void AnakinEngine::BindInput( auto *tensor = input.second; auto *data = tensor->data(); - auto fluid_input_shape = framework::vectorize2int(tensor->dims()); + auto fluid_input_shape = framework::vectorize(tensor->dims()); while (fluid_input_shape.size() < 4) { fluid_input_shape.push_back(1); } diff --git a/paddle/fluid/inference/api/api_impl_tester.cc b/paddle/fluid/inference/api/api_impl_tester.cc index 2dc5dda34d02c6df9c0ccbc47a1ac960e1aca3f5..c80187adfa721fb0a81652ae59556ad4ad9a3e88 100644 --- a/paddle/fluid/inference/api/api_impl_tester.cc +++ b/paddle/fluid/inference/api/api_impl_tester.cc @@ -48,7 +48,7 @@ PaddleTensor LodTensorToPaddleTensor(framework::LoDTensor* t) { } else { LOG(FATAL) << "unsupported type."; } - pt.shape = framework::vectorize2int(t->dims()); + pt.shape = framework::vectorize(t->dims()); return pt; } diff --git a/paddle/fluid/inference/api/details/zero_copy_tensor.cc b/paddle/fluid/inference/api/details/zero_copy_tensor.cc index 937b6398f8131a6cf4e8b0002e38f4513f0f884f..88489078eaef0d9214030edfbe49d31e14c1b88c 100644 --- a/paddle/fluid/inference/api/details/zero_copy_tensor.cc +++ b/paddle/fluid/inference/api/details/zero_copy_tensor.cc @@ -172,7 +172,7 @@ void *ZeroCopyTensor::FindTensor() const { std::vector ZeroCopyTensor::shape() const { EAGER_GET_TENSOR; PADDLE_ENFORCE(tensor_, "not found tensor called %s in the scope", name_); - return framework::vectorize2int(tensor->dims()); + return framework::vectorize(tensor->dims()); } void ZeroCopyTensor::SetLoD(const std::vector> &x) { diff --git a/paddle/fluid/inference/tensorrt/convert/elementwise_op.cc b/paddle/fluid/inference/tensorrt/convert/elementwise_op.cc index a888b0803dfef50859e89bc07b3d4daa609e05cd..c61dd753a33e2eca1c62f13c1d310faa89ccce32 100644 --- a/paddle/fluid/inference/tensorrt/convert/elementwise_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/elementwise_op.cc @@ -61,7 +61,7 @@ class ElementwiseWeightOpConverter : public OpConverter { auto scale_mode = nvinfer1::ScaleMode::kELEMENTWISE; - std::vector dims_y = framework::vectorize2int(Y_t->dims()); + std::vector dims_y = framework::vectorize(Y_t->dims()); if (static_cast(dims_y.size()) == dims_x.nbDims + 1) { if (dims_y[0] == 1) dims_y.erase(dims_y.begin()); } diff --git a/paddle/fluid/operators/elementwise/mkldnn/elementwise_add_mkldnn_op.cc b/paddle/fluid/operators/elementwise/mkldnn/elementwise_add_mkldnn_op.cc index 505294bad773f8d1d86058a55bcf0c77b45905d6..542b31790f42deec8b8d412ff70429acda0f8028 100644 --- a/paddle/fluid/operators/elementwise/mkldnn/elementwise_add_mkldnn_op.cc +++ b/paddle/fluid/operators/elementwise/mkldnn/elementwise_add_mkldnn_op.cc @@ -56,7 +56,7 @@ class EltwiseAddMKLDNNKernel : public framework::OpKernel { if (x_dims != y_dims_untrimed) { Tensor _x; MKLDNNMemoryFormat format; - std::vector src_x_tz = framework::vectorize2int(x_dims); + std::vector src_x_tz = framework::vectorize(x_dims); if ((src_x_tz.size() == 3 && x->format() != (format = MKLDNNMemoryFormat::ncw)) || @@ -129,9 +129,9 @@ class EltwiseAddMKLDNNKernel : public framework::OpKernel { PADDLE_ENFORCE_NE(y->format(), MKLDNNMemoryFormat::format_undef, "Wrong format set for Y tensor"); - std::vector src_x_tz = framework::vectorize2int(x_dims); - std::vector src_y_tz = framework::vectorize2int(y_dims_untrimed); - std::vector dst_tz = framework::vectorize2int(z_dims); + std::vector src_x_tz = framework::vectorize(x_dims); + std::vector src_y_tz = framework::vectorize(y_dims_untrimed); + std::vector dst_tz = framework::vectorize(z_dims); std::vector srcs_pd; std::vector scales = {1.0f, 1.0f}; diff --git a/paddle/fluid/operators/elementwise/mkldnn/elementwise_mul_mkldnn_op.cc b/paddle/fluid/operators/elementwise/mkldnn/elementwise_mul_mkldnn_op.cc index 43aa1fcfb1f8ad305da2628c32e1906a653157eb..cc723844278687c43faa3bd312acec193f550e02 100644 --- a/paddle/fluid/operators/elementwise/mkldnn/elementwise_mul_mkldnn_op.cc +++ b/paddle/fluid/operators/elementwise/mkldnn/elementwise_mul_mkldnn_op.cc @@ -48,7 +48,7 @@ static void ReorderInput(framework::Tensor* tensor, const platform::Place& place, const mkldnn::engine& engine, bool isFourDim) { using platform::to_void_cast; - auto dims = paddle::framework::vectorize2int(tensor->dims()); + auto dims = paddle::framework::vectorize(tensor->dims()); framework::Tensor out_tensor; out_tensor.Resize(tensor->dims()); out_tensor.set_format(isFourDim ? MKLDNNMemoryFormat::nchw @@ -80,7 +80,7 @@ class ElementwiseMulMKLDNNKernel : public framework::OpKernel { auto x_dims = x->dims(); auto y_dims_untrimmed = y->dims(); - auto x_int_dims = paddle::framework::vectorize2int(x_dims); + auto x_int_dims = paddle::framework::vectorize(x_dims); UpdateDataFormat(ctx, const_cast(x), "x_data_format"); UpdateDataFormat(ctx, const_cast(y), "y_data_format"); diff --git a/paddle/fluid/operators/stack_op.h b/paddle/fluid/operators/stack_op.h index 3d132e4397e837442d406e1668126da9163129ef..9ebf166d7034cd55d9f920128580d06e53cfac18 100644 --- a/paddle/fluid/operators/stack_op.h +++ b/paddle/fluid/operators/stack_op.h @@ -14,6 +14,7 @@ #pragma once +#include #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/for_range.h" @@ -50,7 +51,7 @@ class StackOp : public framework::OperatorWithKernel { "Attr(axis) must be inside [-(rank+1), rank+1), where rank = %d", rank); if (axis < 0) axis += (rank + 1); - auto vec = framework::vectorize2int(input_dims[0]); + auto vec = framework::vectorize(input_dims[0]); vec.insert(vec.begin() + axis, input_dims.size()); ctx->SetOutputDim("Y", framework::make_ddim(vec)); } @@ -196,7 +197,7 @@ class StackOpGrad : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ(ctx->Outputs(framework::GradVarName("X")).size(), static_cast(dy_dim[axis]), "Number of Outputs(X@Grad) is wrong"); - auto vec = framework::vectorize2int(dy_dim); + auto vec = framework::vectorize(dy_dim); vec.erase(vec.begin() + axis); ctx->SetOutputsDim( framework::GradVarName("X"), diff --git a/paddle/fluid/operators/unstack_op.h b/paddle/fluid/operators/unstack_op.h index 348a1038804ccb2551e5f729cc1a38bcef1511f5..6247a1f1d94273d1095f3212fb88e53f2da687a0 100644 --- a/paddle/fluid/operators/unstack_op.h +++ b/paddle/fluid/operators/unstack_op.h @@ -14,6 +14,7 @@ #pragma once +#include #include "paddle/fluid/framework/op_registry.h" namespace paddle { @@ -38,7 +39,7 @@ class UnStackOpInferShape : public framework::InferShapeBase { if (x_dim[axis] > 0) { PADDLE_ENFORCE_EQ(num, x_dim[axis], "Number of Outputs(Y) is wrong"); } - auto vec = framework::vectorize2int(x_dim); + auto vec = framework::vectorize(x_dim); vec.erase(vec.begin() + axis); ctx->SetOutputsDim("Y", std::vector( // NOLINT x_dim[axis], framework::make_ddim(vec))); @@ -96,7 +97,7 @@ class UnStackOpGradInferShape : public framework::InferShapeBase { "Attr(axis) must be inside [-(rank+1), rank+1), where rank = %d", rank); if (axis < 0) axis += (rank + 1); - auto vec = framework::vectorize2int(input_dims[0]); + auto vec = framework::vectorize(input_dims[0]); vec.insert(vec.begin() + axis, input_dims.size()); ctx->SetOutputDim(framework::GradVarName("X"), framework::make_ddim(vec)); } diff --git a/paddle/fluid/platform/cudnn_desc.h b/paddle/fluid/platform/cudnn_desc.h index 39a50b3bc99d5bd699afa8cf717e5962b792d1ae..f503dfb3878464fd13d977e377fbcc4e5fd4dc1a 100644 --- a/paddle/fluid/platform/cudnn_desc.h +++ b/paddle/fluid/platform/cudnn_desc.h @@ -102,7 +102,7 @@ class TensorDescriptor { T* desc() { return desc_.get(); } T* desc() const { return desc_.get(); } void set(const Tensor& tensor, const int groups = 1) { - auto dims = framework::vectorize2int(tensor.dims()); + auto dims = framework::vectorize(tensor.dims()); std::vector strides(dims.size()); strides[dims.size() - 1] = 1; for (int i = dims.size() - 2; i >= 0; i--) { @@ -142,7 +142,7 @@ class FilterDescriptor { void set(const Tensor& tensor, const cudnnTensorFormat_t format, const int groups = 1) { - auto dims = framework::vectorize2int(tensor.dims()); + auto dims = framework::vectorize(tensor.dims()); if (groups > 1) { dims[1] = dims[1] / groups; } diff --git a/paddle/fluid/pybind/imperative.cc b/paddle/fluid/pybind/imperative.cc index 999251ff57b9dc578c1fbd29fc24dfe85ca7c4a3..82867faff8274c3c1bf28a2cf10e5da49f9dece0 100644 --- a/paddle/fluid/pybind/imperative.cc +++ b/paddle/fluid/pybind/imperative.cc @@ -290,7 +290,7 @@ void BindImperative(py::module *m_ptr) { "shape", [](imperative::VarBase &self) { if (self.Var().IsType()) { - return framework::vectorize2int( + return framework::vectorize( self.Var().Get().dims()); } else { VLOG(2) << "It is meaningless to get shape of variable type "