diff --git a/paddle/fluid/distributed/collective/reducer.cc b/paddle/fluid/distributed/collective/reducer.cc index 79961cca85ae03d654ea59b4e58c814dd2c4c543..ec02406efc81804d0ffdf033ed7d61ef97d68c9a 100644 --- a/paddle/fluid/distributed/collective/reducer.cc +++ b/paddle/fluid/distributed/collective/reducer.cc @@ -320,7 +320,7 @@ EagerReducer::EagerReducer( if (find_unused_vars_each_step_) { global_used_vars_ = paddle::experimental::empty( - ScalarArray({static_cast(tensors_.size())}), DataType::INT32, + IntArray({static_cast(tensors_.size())}), DataType::INT32, inner_place_); } } @@ -364,7 +364,7 @@ void EagerReducer::InitializeGroups( // process the dense gradient. InitializeDenseGroups(tensor_indices_, &group); group.dense_contents_ = paddle::experimental::empty( - ScalarArray({group.all_length_}), group.dtype_, inner_place_); + IntArray({group.all_length_}), group.dtype_, inner_place_); } // map tensors to this group by VariableLocator @@ -403,7 +403,7 @@ void EagerReducer::InitializeDenseGroups( p_group->length_.push_back(size); // for concat operator - p_group->origin_shapes_.push_back(ScalarArray(tensor.shape())); + p_group->origin_shapes_.push_back(IntArray(tensor.shape())); p_group->dense_tensors_.push_back(phi::DenseTensor()); const auto &dtype = tensor.dtype(); diff --git a/paddle/fluid/distributed/collective/reducer.h b/paddle/fluid/distributed/collective/reducer.h index d3ffa8498a14b0d0ade02ea459e1c6058550122f..848277f5fad4ea6fb5ea34f8697d2076fb4a62f0 100644 --- a/paddle/fluid/distributed/collective/reducer.h +++ b/paddle/fluid/distributed/collective/reducer.h @@ -35,8 +35,8 @@ namespace paddle { namespace distributed { using Tensor = paddle::experimental::Tensor; using Scalar = paddle::experimental::ScalarBase; -using ScalarArray = - paddle::experimental::ScalarArrayBase; +using IntArray = + paddle::experimental::IntArrayBase; using Backend = paddle::experimental::Backend; std::vector> Eager_AssignGroupBySize( @@ -52,7 +52,7 @@ class EagerGroup { std::vector dense_tensors_; std::vector length_; int64_t all_length_{0}; - std::vector origin_shapes_; + std::vector origin_shapes_; // Global indices of participating tensors in the group std::vector tensor_indices_; diff --git a/paddle/fluid/eager/auto_code_generator/final_state_generator/codegen_utils.py b/paddle/fluid/eager/auto_code_generator/final_state_generator/codegen_utils.py index 16578584cb7c1c161b1bd434176cf837b8865183..8b7ea547b2632a052d58d0c7679130dc925d5fcf 100644 --- a/paddle/fluid/eager/auto_code_generator/final_state_generator/codegen_utils.py +++ b/paddle/fluid/eager/auto_code_generator/final_state_generator/codegen_utils.py @@ -43,7 +43,7 @@ yaml_types_mapping = { 'Scalar(int64_t)' : 'paddle::experimental::Scalar', 'Scalar(float)' : 'paddle::experimental::Scalar', 'Scalar(double)' : 'paddle::experimental::Scalar', - 'ScalarArray' : 'paddle::experimental::ScalarArray' + 'IntArray' : 'paddle::experimental::IntArray' } diff --git a/paddle/fluid/eager/auto_code_generator/final_state_generator/python_c_gen.py b/paddle/fluid/eager/auto_code_generator/final_state_generator/python_c_gen.py index 63eb1ee46a822be651f6427f8544112f1ed56132..463c50658cd328e5f7c5b05df80397ae87e00d55 100644 --- a/paddle/fluid/eager/auto_code_generator/final_state_generator/python_c_gen.py +++ b/paddle/fluid/eager/auto_code_generator/final_state_generator/python_c_gen.py @@ -45,7 +45,7 @@ atype_to_parsing_function = { "std::vector": "CastPyArg2Float64s", "std::vector": "CastPyArg2Strings", "paddle::experimental::Scalar": "CastPyArg2Scalar", - "paddle::experimental::ScalarArray": "CastPyArg2ScalarArray", + "paddle::experimental::IntArray": "CastPyArg2IntArray", "paddle::experimental::Place": "CastPyArg2Place", "paddle::experimental::DataType": "CastPyArg2DataType", } @@ -140,7 +140,7 @@ PYTHON_C_WRAPPER_TEMPLATE = \ #include "paddle/phi/common/backend.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/api/include/sparse_api.h" #include "paddle/phi/api/include/strings_api.h" #include "paddle/fluid/pybind/op_function_common.h" diff --git a/paddle/fluid/framework/infershape_utils.cc b/paddle/fluid/framework/infershape_utils.cc index cb34c52e52672e0d479f98a96262aed924ca630b..ecc5fbdcf945d82f022ebf7dc012ffabddd1c846 100644 --- a/paddle/fluid/framework/infershape_utils.cc +++ b/paddle/fluid/framework/infershape_utils.cc @@ -21,8 +21,8 @@ limitations under the License. */ #include "paddle/fluid/framework/framework.pb.h" #include "paddle/fluid/framework/phi_utils.h" #include "paddle/fluid/platform/enforce.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/compat/arg_map_context.h" #include "paddle/phi/core/compat/convert_utils.h" #include "paddle/phi/core/compat/op_utils.h" @@ -363,12 +363,12 @@ phi::InferMetaContext BuildInferMetaContext(InferShapeContext* ctx, auto attr_reader = ctx->Attrs(); for (size_t i = 0; i < attr_names.size(); ++i) { auto attr_name = attr_names[i]; - if (attr_defs[i].type_index == std::type_index(typeid(phi::ScalarArray))) { - // When attr is a vector_tensor or tensor, transform it to ScalarArray + if (attr_defs[i].type_index == std::type_index(typeid(phi::IntArray))) { + // When attr is a vector_tensor or tensor, transform it to IntArray if (ctx->HasInputs(attr_name) || ctx->HasInput(attr_name)) { const auto& infershape_inputs = ctx->GetInputVarPtrs(attr_name); if (ctx->IsRuntime()) { - // If is in runtime, we will get tensor's value for ScalarArray + // If is in runtime, we will get tensor's value for IntArray // and push it into attrs std::vector vars; vars.reserve(infershape_inputs.size()); @@ -377,13 +377,13 @@ phi::InferMetaContext BuildInferMetaContext(InferShapeContext* ctx, } if (infershape_inputs.size() != 1) { infer_meta_context.EmplaceBackAttr( - std::move(experimental::MakePhiScalarArrayFromVarList(vars))); + std::move(experimental::MakePhiIntArrayFromVarList(vars))); } else { infer_meta_context.EmplaceBackAttr( - std::move(experimental::MakePhiScalarArrayFromVar(*vars[0]))); + std::move(experimental::MakePhiIntArrayFromVar(*vars[0]))); } } else { - // If is not in runtime, we will set default value(-1) for ScalarArray + // If is not in runtime, we will set default value(-1) for IntArray std::vector vars; vars.reserve(infershape_inputs.size()); for (size_t i = 0; i < infershape_inputs.size(); ++i) { @@ -400,7 +400,7 @@ phi::InferMetaContext BuildInferMetaContext(InferShapeContext* ctx, if (num_ele <= 0) { PADDLE_THROW(platform::errors::Unimplemented( - "Invalid number for construct phi::ScalarArray, expected " + "Invalid number for construct phi::IntArray, expected " "number > 0, but actually is %d. ", num_ele)); } @@ -408,7 +408,7 @@ phi::InferMetaContext BuildInferMetaContext(InferShapeContext* ctx, } else { num_ele = vars.size(); } - phi::ScalarArray tensor_attr(std::vector(num_ele, -1)); + phi::IntArray tensor_attr(std::vector(num_ele, -1)); tensor_attr.SetFromTensor(true); infer_meta_context.EmplaceBackAttr(std::move(tensor_attr)); } @@ -417,18 +417,18 @@ phi::InferMetaContext BuildInferMetaContext(InferShapeContext* ctx, if (std::type_index(attr.type()) == std::type_index(typeid(std::vector))) { infer_meta_context.EmplaceBackAttr(std::move( - phi::ScalarArray(BOOST_GET_CONST(std::vector, attr)))); + phi::IntArray(BOOST_GET_CONST(std::vector, attr)))); } else if (std::type_index(attr.type()) == std::type_index(typeid(std::vector))) { infer_meta_context.EmplaceBackAttr(std::move( - phi::ScalarArray(BOOST_GET_CONST(std::vector, attr)))); + phi::IntArray(BOOST_GET_CONST(std::vector, attr)))); } else if (std::type_index(attr.type()) == std::type_index(typeid(int))) { infer_meta_context.EmplaceBackAttr( - phi::ScalarArray({BOOST_GET_CONST(int, attr)})); + phi::IntArray({BOOST_GET_CONST(int, attr)})); } else { PADDLE_THROW(platform::errors::Unimplemented( - "Unsupported cast op attribute `%s` to ScalarArray when " + "Unsupported cast op attribute `%s` to IntArray when " "construct InferMetaContext.", attr_name)); } diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index cf2a36cde1f1f68bf33a29b142611a08d95aec33..4183360f655a7bc4610bacf3d1aafbe0c44469f4 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -33,8 +33,8 @@ limitations under the License. */ #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/profiler.h" #include "paddle/fluid/platform/profiler/event_tracing.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/kernel_factory.h" #include "paddle/phi/ops/compat/signatures.h" @@ -2198,24 +2198,24 @@ void OperatorWithKernel::BuildPhiKernelContext( VLOG(4) << "Done outputs"; for (size_t i = 0; i < attr_names.size(); ++i) { - if (attr_defs[i].type_index == std::type_index(typeid(phi::ScalarArray))) { + if (attr_defs[i].type_index == std::type_index(typeid(phi::IntArray))) { auto attr_iter = Attrs().find(attr_names[i]); if (attr_iter != Attrs().end()) { // shape is in the attribute if (std::type_index(attr_iter->second.type()) == std::type_index(typeid(std::vector))) { - pt_kernel_context->EmplaceBackAttr(std::move(phi::ScalarArray( + pt_kernel_context->EmplaceBackAttr(std::move(phi::IntArray( BOOST_GET_CONST(std::vector, attr_iter->second)))); } else if (std::type_index(attr_iter->second.type()) == std::type_index(typeid(std::vector))) { - pt_kernel_context->EmplaceBackAttr(std::move(phi::ScalarArray( + pt_kernel_context->EmplaceBackAttr(std::move(phi::IntArray( BOOST_GET_CONST(std::vector, attr_iter->second)))); } else if (std::type_index(attr_iter->second.type()) == std::type_index(typeid(int32_t))) { - pt_kernel_context->EmplaceBackAttr(std::move(phi::ScalarArray( - &BOOST_GET_CONST(int32_t, attr_iter->second), 1))); + pt_kernel_context->EmplaceBackAttr(std::move( + phi::IntArray(&BOOST_GET_CONST(int32_t, attr_iter->second), 1))); } else { PADDLE_THROW(platform::errors::Unimplemented( - "Unsupported cast op attribute `%s` to ScalarArray when " + "Unsupported cast op attribute `%s` to IntArray when " "construct KernelContext.", attr_names[i])); } @@ -2223,10 +2223,10 @@ void OperatorWithKernel::BuildPhiKernelContext( auto& ins_vector = ctx.inputs.at(attr_names[i]); if (ins_vector.size() == 1) { // ShapeTensor pt_kernel_context->EmplaceBackAttr(std::move( - experimental::MakePhiScalarArrayFromVar(*ins_vector.front()))); + experimental::MakePhiIntArrayFromVar(*ins_vector.front()))); } else { // ShapeTensorList - pt_kernel_context->EmplaceBackAttr(std::move( - experimental::MakePhiScalarArrayFromVarList(ins_vector))); + pt_kernel_context->EmplaceBackAttr( + std::move(experimental::MakePhiIntArrayFromVarList(ins_vector))); } } } else if (attr_defs[i].type_index == diff --git a/paddle/fluid/imperative/prepared_operator.cc b/paddle/fluid/imperative/prepared_operator.cc index ffac264b51d502242aa4e8c7afebc88b03c5b6f0..f7d2ef1bf5d423af756aa4e89712a7bb0d5dd7ee 100644 --- a/paddle/fluid/imperative/prepared_operator.cc +++ b/paddle/fluid/imperative/prepared_operator.cc @@ -19,8 +19,8 @@ #include "paddle/fluid/framework/details/nan_inf_utils.h" #include "paddle/fluid/imperative/infer_shape_context.h" #include "paddle/fluid/imperative/tracer.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/utils/small_vector.h" #ifdef PADDLE_WITH_XPU #include "paddle/fluid/platform/device/xpu/xpu_op_list.h" diff --git a/paddle/fluid/imperative/prepared_operator.h b/paddle/fluid/imperative/prepared_operator.h index 9daac181d57de63a85116d176a286a9be9b3d4c7..43bed5fd35e2f9c12c65a12b4ad78bba8a832ef7 100644 --- a/paddle/fluid/imperative/prepared_operator.h +++ b/paddle/fluid/imperative/prepared_operator.h @@ -361,26 +361,26 @@ void BuildDygraphPhiKernelContext( } for (size_t i = 0; i < attr_names.size(); ++i) { - if (attr_defs[i].type_index == std::type_index(typeid(phi::ScalarArray))) { + if (attr_defs[i].type_index == std::type_index(typeid(phi::IntArray))) { if (attrs.find(attr_names[i]) != attrs.end()) { // shape is in the attribute auto& attr = GetAttr(attrs, default_attrs, attr_names[i]); if (std::type_index(attr.type()) == std::type_index(typeid(std::vector))) { kernel_ctx->EmplaceBackAttr(std::move( - phi::ScalarArray(BOOST_GET_CONST(std::vector, attr)))); + phi::IntArray(BOOST_GET_CONST(std::vector, attr)))); } else if (std::type_index(attr.type()) == std::type_index(typeid(std::vector))) { kernel_ctx->EmplaceBackAttr(std::move( - phi::ScalarArray(BOOST_GET_CONST(std::vector, attr)))); + phi::IntArray(BOOST_GET_CONST(std::vector, attr)))); } else if (std::type_index(attr.type()) == std::type_index(typeid(int64_t))) { kernel_ctx->EmplaceBackAttr( - std::move(phi::ScalarArray(&BOOST_GET_CONST(int64_t, attr), 1))); + std::move(phi::IntArray(&BOOST_GET_CONST(int64_t, attr), 1))); } else if (std::type_index(attr.type()) == std::type_index(typeid(int32_t))) { kernel_ctx->EmplaceBackAttr( - std::move(phi::ScalarArray(&BOOST_GET_CONST(int32_t, attr), 1))); + std::move(phi::IntArray(&BOOST_GET_CONST(int32_t, attr), 1))); } else if (attr_defs[i].type_index == std::type_index(typeid(std::vector))) { const auto& vector_int_attr = BOOST_GET_CONST(std::vector, attr); @@ -395,15 +395,15 @@ void BuildDygraphPhiKernelContext( auto& ins_vector = ins.at(attr_names[i]); if (ins_vector.size() == 1) { // ShapeTensor kernel_ctx->EmplaceBackAttr(std::move( - experimental::MakePhiScalarArrayFromVar(ins_vector[0]->Var()))); + experimental::MakePhiIntArrayFromVar(ins_vector[0]->Var()))); } else { // ShapeTensorList std::vector variables; variables.reserve(ins_vector.size()); for (const auto& var_base : ins_vector) { variables.push_back(var_base->MutableVar()); } - kernel_ctx->EmplaceBackAttr(std::move( - experimental::MakePhiScalarArrayFromVarList(variables))); + kernel_ctx->EmplaceBackAttr( + std::move(experimental::MakePhiIntArrayFromVarList(variables))); } } } else if (attr_defs[i].type_index == diff --git a/paddle/fluid/operators/reshape_op.cc b/paddle/fluid/operators/reshape_op.cc index 4a4210845ca085d7f88fa55d99e3394295a07d1b..0befc873ed696e0770b2819ceddb79a8472dafd9 100644 --- a/paddle/fluid/operators/reshape_op.cc +++ b/paddle/fluid/operators/reshape_op.cc @@ -21,7 +21,7 @@ limitations under the License. */ // only can include the headers in paddle/phi/api dirs #include "paddle/phi/api/lib/utils/tensor_utils.h" #include "paddle/phi/backends/cpu/cpu_context.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/backward.h" #include "paddle/phi/infermeta/unary.h" @@ -354,7 +354,7 @@ class ReshapeKernel { auto *shape_tensor = ctx.HasInput("Shape") ? ctx.Input("Shape") : nullptr; - phi::ScalarArray pt_scalar_shape; + phi::IntArray pt_scalar_shape; if (list_new_shape_tensor.size() > 0) { // have shape tensor std::vector pt_vec_shape; @@ -369,7 +369,7 @@ class ReshapeKernel { pt_vec_shape.push_back(*tensor); } } - pt_scalar_shape = phi::ScalarArray(pt_vec_shape); + pt_scalar_shape = phi::IntArray(pt_vec_shape); } else if (shape_tensor) { phi::DenseTensor pt_shape; if (platform::is_gpu_place(shape_tensor->place()) || @@ -381,10 +381,10 @@ class ReshapeKernel { } else { pt_shape = *shape_tensor; } - pt_scalar_shape = phi::ScalarArray(pt_shape); + pt_scalar_shape = phi::IntArray(pt_shape); } else { auto &shape_attr = ctx.Attr>("shape"); - pt_scalar_shape = phi::ScalarArray(shape_attr); + pt_scalar_shape = phi::IntArray(shape_attr); } if (platform::is_cpu_place(ctx.GetPlace())) { auto &dev_ctx = ctx.device_context(); diff --git a/paddle/fluid/pybind/eager_utils.cc b/paddle/fluid/pybind/eager_utils.cc index af89861d151bea3eb3eadee4a9dbbaff3fcc0566..bee3e27a55167228eb6559c656c4185a9bac4146 100644 --- a/paddle/fluid/pybind/eager_utils.cc +++ b/paddle/fluid/pybind/eager_utils.cc @@ -950,9 +950,10 @@ paddle::experimental::Scalar CastPyArg2Scalar(PyObject* obj, return paddle::experimental::Scalar(1.0); } -paddle::experimental::ScalarArray CastPyArg2ScalarArray( - PyObject* obj, const std::string& op_type, ssize_t arg_pos) { - // In case of ScalarArray, only two possible PyObjects: +paddle::experimental::IntArray CastPyArg2IntArray(PyObject* obj, + const std::string& op_type, + ssize_t arg_pos) { + // In case of IntArray, only two possible PyObjects: // 1. list of int // 2. Tensor if (obj == Py_None) { @@ -968,12 +969,12 @@ paddle::experimental::ScalarArray CastPyArg2ScalarArray( auto type_name = std::string(type->tp_name); if (type_name == "list" || type_name == "tuple") { std::vector value = CastPyArg2Ints(obj, op_type, arg_pos); - return paddle::experimental::ScalarArray(value); + return paddle::experimental::IntArray(value); } else if (type_name == "paddle.Tensor") { paddle::experimental::Tensor& value = GetTensorFromPyObject( op_type, "" /*arg_name*/, obj, arg_pos, false /*dispensable*/); - return paddle::experimental::ScalarArray(value); + return paddle::experimental::IntArray(value); } else { PADDLE_THROW(platform::errors::InvalidArgument( @@ -983,8 +984,8 @@ paddle::experimental::ScalarArray CastPyArg2ScalarArray( ((PyTypeObject*)obj->ob_type)->tp_name)); // NOLINT } - // Fake a ScalarArray - return paddle::experimental::ScalarArray({1}); + // Fake a IntArray + return paddle::experimental::IntArray({1}); } paddle::framework::Scope* CastPyArg2ScopePtr(PyObject* obj) { diff --git a/paddle/fluid/pybind/eager_utils.h b/paddle/fluid/pybind/eager_utils.h index 15d289d7bc37d9ab2124c511b02c6b0f374b1ba9..bd78342e21f4b4fa508bd501e1d0f449f7a357fe 100644 --- a/paddle/fluid/pybind/eager_utils.h +++ b/paddle/fluid/pybind/eager_utils.h @@ -13,8 +13,8 @@ limitations under the License. */ #include #include "paddle/phi/common/backend.h" #include "paddle/phi/common/data_type.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/dense_tensor.h" #include "pybind11/pybind11.h" @@ -150,8 +150,9 @@ paddle::experimental::Scalar CastPyArg2Scalar(PyObject* obj, const std::string& op_type, ssize_t arg_pos); -paddle::experimental::ScalarArray CastPyArg2ScalarArray( - PyObject* obj, const std::string& op_type, ssize_t arg_pos); +paddle::experimental::IntArray CastPyArg2IntArray(PyObject* obj, + const std::string& op_type, + ssize_t arg_pos); paddle::experimental::Place CastPyArg2Place(PyObject* obj, const std::string& op_type, diff --git a/paddle/infrt/host_context/value.h b/paddle/infrt/host_context/value.h index b0f56f020f4866053d99b01cdc721dfd9f295a36..ecd118818099df299a1ad9f90756c108dc3d5a5c 100644 --- a/paddle/infrt/host_context/value.h +++ b/paddle/infrt/host_context/value.h @@ -38,9 +38,9 @@ #include "paddle/phi/backends/all_context.h" #include "paddle/phi/common/backend.h" #include "paddle/phi/common/data_type.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/layout.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/meta_tensor.h" @@ -90,7 +90,7 @@ using ValueVariantType = std::vector, std::vector<::phi::DenseTensor*>, paddle::experimental::ScalarBase<::phi::DenseTensor>, - paddle::experimental::ScalarArrayBase<::phi::DenseTensor>, + paddle::experimental::IntArrayBase<::phi::DenseTensor>, std::vector<::phi::MetaTensor*>, ::phi::MetaConfig, paddle::experimental::Backend, diff --git a/paddle/phi/api/all.h b/paddle/phi/api/all.h index 154b84670aaf992833fccf9297d8b16a081e173f..4e0a4729916b36cdf0457c5eeb50d2a70cceb9a2 100644 --- a/paddle/phi/api/all.h +++ b/paddle/phi/api/all.h @@ -32,9 +32,9 @@ limitations under the License. */ // phi common headers #include "paddle/phi/common/backend.h" #include "paddle/phi/common/data_type.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/layout.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" // original custom op headers #include "paddle/phi/api/ext/dispatch.h" diff --git a/paddle/phi/api/lib/api_custom_impl.cc b/paddle/phi/api/lib/api_custom_impl.cc index 1f6c37aa090e8c8060a5f7160398327ae7991fa1..152873fe410726e5567482325334e1ef05bdf82f 100644 --- a/paddle/phi/api/lib/api_custom_impl.cc +++ b/paddle/phi/api/lib/api_custom_impl.cc @@ -64,7 +64,7 @@ Tensor copy_to_impl(const Tensor& x, Place place, bool blocking) { } std::vector split_impl(const Tensor& x, - const ScalarArray& num_or_sections, + const IntArray& num_or_sections, const Scalar& axis) { auto kernel_key_set = ParseKernelKeyByInputArgs(x); auto kernel_key = kernel_key_set.GetHighestPriorityKernelKey(); @@ -107,13 +107,13 @@ std::vector split_impl(const Tensor& x, using kernel_signature = void (*)(const platform::DeviceContext&, const phi::DenseTensor&, - const phi::ScalarArray&, + const phi::IntArray&, const phi::Scalar&, std::vector&); auto* kernel_fn = kernel.GetVariadicKernelFn(); (*kernel_fn)(*dev_ctx, *dense_x, - phi::ScalarArray(num_or_sections), + phi::IntArray(num_or_sections), phi::Scalar(axis), dense_outs); diff --git a/paddle/phi/api/lib/api_custom_impl.h b/paddle/phi/api/lib/api_custom_impl.h index 48eda2d954647e8c2786b29b615cfc6166734bca..b2f5a074d928815b620409f14c0be7eee35958e9 100644 --- a/paddle/phi/api/lib/api_custom_impl.h +++ b/paddle/phi/api/lib/api_custom_impl.h @@ -15,9 +15,9 @@ limitations under the License. */ #pragma once #include "paddle/phi/api/include/tensor.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/place.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" namespace paddle { namespace experimental { @@ -25,7 +25,7 @@ namespace experimental { Tensor copy_to_impl(const Tensor& x, Place place, bool blocking); std::vector split_impl(const Tensor& x, - const ScalarArray& num_or_sections, + const IntArray& num_or_sections, const Scalar& axis); } // namespace experimental diff --git a/paddle/phi/api/lib/tensor_method.cc b/paddle/phi/api/lib/tensor_method.cc index dde9980d0b951421c3c69b8a9b0506e56939af7b..7d9f7a7ae17c8670fd8ebd15db9b3d8d510df519 100644 --- a/paddle/phi/api/lib/tensor_method.cc +++ b/paddle/phi/api/lib/tensor_method.cc @@ -15,7 +15,7 @@ limitations under the License. */ #include "paddle/phi/api/include/tensor.h" #include "paddle/phi/api/lib/ext_compat_utils.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/compat/convert_utils.h" #include "paddle/phi/core/tensor_base.h" diff --git a/paddle/phi/api/lib/utils/tensor_utils.cc b/paddle/phi/api/lib/utils/tensor_utils.cc index 3d183ea7fee8b17a7037a3fd9a6b2999605d8e25..5a6f1b1a7ee0cd7c2dee9e52d79a3efc50596c87 100644 --- a/paddle/phi/api/lib/utils/tensor_utils.cc +++ b/paddle/phi/api/lib/utils/tensor_utils.cc @@ -62,35 +62,34 @@ phi::Scalar MakePhiScalarFromVar(const framework::Variable& variable) { } } -phi::ScalarArray MakePhiScalarArray(const paddle::framework::Tensor& src) { +phi::IntArray MakePhiIntArray(const paddle::framework::Tensor& src) { return {src}; } -phi::ScalarArray MakePhiScalarArrayFromVar( - const framework::Variable& variable) { +phi::IntArray MakePhiIntArrayFromVar(const framework::Variable& variable) { auto expected_place = phi::TransToPhiPlace(phi::Backend::CPU); if (variable.IsType()) { const auto& tensor = variable.Get(); if (!platform::is_same_place(tensor.place(), expected_place)) { framework::LoDTensor tmp_tensor; framework::TensorCopySync(tensor, expected_place, &tmp_tensor); - return MakePhiScalarArray(tmp_tensor); + return MakePhiIntArray(tmp_tensor); } else { - return MakePhiScalarArray(tensor); + return MakePhiIntArray(tensor); } } else { PADDLE_THROW(platform::errors::Unimplemented( - "Unsupport casting input `%s` type to ScalarArray when call pt " + "Unsupport casting input `%s` type to IntArray when call pt " "kernel.", framework::ToTypeName(variable.Type()))); } } -// TODO(chentianyu03): Inplace with ScalarArray constructor -phi::ScalarArray MakePhiScalarArrayFromVarList( +// TODO(chentianyu03): Inplace with IntArray constructor +phi::IntArray MakePhiIntArrayFromVarList( const std::vector& variable_list) { if (variable_list.size() == 0) { - return phi::ScalarArray(); + return phi::IntArray(); } auto expected_place = phi::TransToPhiPlace(phi::Backend::CPU); @@ -137,7 +136,7 @@ phi::ScalarArray MakePhiScalarArrayFromVarList( } } - phi::ScalarArray result{vector_data}; + phi::IntArray result{vector_data}; result.SetFromTensor(true); return result; diff --git a/paddle/phi/api/lib/utils/tensor_utils.h b/paddle/phi/api/lib/utils/tensor_utils.h index 64df59c1a2a2de3f72ce46874fe07df70d33599e..00199da1280e80ac310390ae3748a0d6b9a2815d 100644 --- a/paddle/phi/api/lib/utils/tensor_utils.h +++ b/paddle/phi/api/lib/utils/tensor_utils.h @@ -21,8 +21,8 @@ limitations under the License. */ #include "paddle/phi/api/lib/utils/allocator.h" #include "paddle/phi/api/lib/utils/storage.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/compat/convert_utils.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/kernel_factory.h" @@ -33,13 +33,13 @@ namespace experimental { std::unique_ptr MakePhiDenseTensor( const paddle::framework::Tensor& src); -phi::ScalarArray MakePhiScalarArray(const paddle::framework::Tensor& src); +phi::IntArray MakePhiIntArray(const paddle::framework::Tensor& src); phi::Scalar MakePhiScalarFromVar(const framework::Variable& variable); -phi::ScalarArray MakePhiScalarArrayFromVar(const framework::Variable& variable); +phi::IntArray MakePhiIntArrayFromVar(const framework::Variable& variable); -phi::ScalarArray MakePhiScalarArrayFromVarList( +phi::IntArray MakePhiIntArrayFromVarList( const std::vector& variable_list); } // namespace experimental diff --git a/paddle/phi/common/scalar_array.h b/paddle/phi/common/int_array.h similarity index 77% rename from paddle/phi/common/scalar_array.h rename to paddle/phi/common/int_array.h index 39284095961a727d7d0052a589b543df31bd6ebc..490d7dabd4007b7445edfbca0dd2852e4bc2eaab 100644 --- a/paddle/phi/common/scalar_array.h +++ b/paddle/phi/common/int_array.h @@ -21,25 +21,25 @@ namespace paddle { namespace experimental { template -class ScalarArrayBase { +class IntArrayBase { public: // Constructor support implicit - ScalarArrayBase() = default; + IntArrayBase() = default; - ScalarArrayBase(const std::vector& vec) : array_(vec) {} // NOLINT + IntArrayBase(const std::vector& vec) : array_(vec) {} // NOLINT - ScalarArrayBase(const std::vector& vec) { // NOLINT + IntArrayBase(const std::vector& vec) { // NOLINT array_.insert(array_.begin(), vec.begin(), vec.end()); } - ScalarArrayBase(std::initializer_list array_list) + IntArrayBase(std::initializer_list array_list) : array_(array_list) {} - ScalarArrayBase(const int64_t* date_value, int64_t n) { + IntArrayBase(const int64_t* date_value, int64_t n) { AssignData(date_value, n); } - ScalarArrayBase(const int32_t* date_value, int64_t n) { + IntArrayBase(const int32_t* date_value, int64_t n) { AssignData(date_value, n); } @@ -48,7 +48,7 @@ class ScalarArrayBase { void SetFromTensor(bool val) { is_from_tensor_ = val; } // The Tensor must have one dim - ScalarArrayBase(const T& tensor) { // NOLINT + IntArrayBase(const T& tensor) { // NOLINT is_from_tensor_ = true; size_t n = tensor.numel(); array_.reserve(n); @@ -61,7 +61,7 @@ class ScalarArrayBase { break; default: PD_THROW( - "Data type error. Currently, The data type of ScalarArrayBase " + "Data type error. Currently, The data type of IntArrayBase " "only supports Tensor with int32 and int64, " "but now received `", tensor.dtype(), @@ -70,7 +70,7 @@ class ScalarArrayBase { } // The Tensor in vec must have only one element - ScalarArrayBase(const std::vector& tensor_list) { // NOLINT + IntArrayBase(const std::vector& tensor_list) { // NOLINT is_from_tensor_ = true; for (size_t i = 0; i < tensor_list.size(); ++i) { @@ -84,7 +84,7 @@ class ScalarArrayBase { break; default: PD_THROW( - "Data type error. Currently, The data type of ScalarArrayBase " + "Data type error. Currently, The data type of IntArrayBase " "only supports Tensor with int32 and int64, " "but now received `", data_type, @@ -94,8 +94,7 @@ class ScalarArrayBase { } template - ScalarArrayBase(const ScalarArrayBase& other) - : array_(other.GetData()) {} + IntArrayBase(const IntArrayBase& other) : array_(other.GetData()) {} const std::vector& GetData() const { return array_; } @@ -120,8 +119,8 @@ class ScalarArrayBase { bool is_from_tensor_{false}; }; -using ScalarArray = - paddle::experimental::ScalarArrayBase; +using IntArray = + paddle::experimental::IntArrayBase; } // namespace experimental } // namespace paddle @@ -129,6 +128,6 @@ using ScalarArray = namespace phi { class DenseTensor; -using ScalarArray = paddle::experimental::ScalarArrayBase; +using IntArray = paddle::experimental::IntArrayBase; } // namespace phi diff --git a/paddle/phi/core/infermeta_utils.h b/paddle/phi/core/infermeta_utils.h index 9c351ce9063ecf56b76a2eb351d1d2d23f13a83b..0278e444e2de227b10630702dc44b3efd7003c84 100644 --- a/paddle/phi/core/infermeta_utils.h +++ b/paddle/phi/core/infermeta_utils.h @@ -19,8 +19,8 @@ limitations under the License. */ #include #include +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/enforce.h" #include "paddle/phi/core/macros.h" #include "paddle/phi/core/meta_tensor.h" @@ -192,7 +192,7 @@ struct InferMetaFnImpl { PD_SPECIALIZE_InferMetaFnCallHelper_FOR_ATTRIBUTE(Backend); PD_SPECIALIZE_InferMetaFnCallHelper_FOR_ATTRIBUTE(DataLayout); PD_SPECIALIZE_InferMetaFnCallHelper_FOR_ATTRIBUTE(const Scalar&); - PD_SPECIALIZE_InferMetaFnCallHelper_FOR_ATTRIBUTE(const ScalarArray&); + PD_SPECIALIZE_InferMetaFnCallHelper_FOR_ATTRIBUTE(const IntArray&); // TODO(chenweihang): support vector input later diff --git a/paddle/phi/core/kernel_utils.h b/paddle/phi/core/kernel_utils.h index 642dc0b4c830e569232883f1bba2ef00f8acfb14..5317288a2aa8334a0ad170e0a247b534df8cbc2a 100644 --- a/paddle/phi/core/kernel_utils.h +++ b/paddle/phi/core/kernel_utils.h @@ -18,8 +18,8 @@ #include "paddle/phi/backends/custom/custom_context.h" #include "paddle/phi/backends/gpu/gpu_context.h" #include "paddle/phi/backends/xpu/xpu_context.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/enforce.h" #include "paddle/phi/core/kernel_context.h" @@ -250,7 +250,7 @@ struct KernelImpl { PD_SPECIALIZE_KernelCallHelper_FOR_ATTRIBUTE(DataLayout); PD_SPECIALIZE_KernelCallHelper_FOR_ATTRIBUTE(Place); PD_SPECIALIZE_KernelCallHelper_FOR_ATTRIBUTE(const std::vector&); - PD_SPECIALIZE_KernelCallHelper_FOR_ATTRIBUTE(const ScalarArray&); + PD_SPECIALIZE_KernelCallHelper_FOR_ATTRIBUTE(const IntArray&); PD_SPECIALIZE_KernelCallHelper_FOR_ATTRIBUTE(const std::vector&); PD_SPECIALIZE_KernelCallHelper_FOR_ATTRIBUTE(const std::string&); PD_SPECIALIZE_KernelCallHelper_FOR_ATTRIBUTE(const std::vector&); diff --git a/paddle/phi/infermeta/nullary.cc b/paddle/phi/infermeta/nullary.cc index 6c3bbe654faecbfea4d5cef26a3c0123d92b54b5..4a11d24a9868ba07be085f579c622483e2ed988d 100644 --- a/paddle/phi/infermeta/nullary.cc +++ b/paddle/phi/infermeta/nullary.cc @@ -23,9 +23,7 @@ void AssignValueInferMeta(const std::vector& shape, out->set_dtype(dtype); } -void CreateInferMeta(const ScalarArray& shape, - DataType dtype, - MetaTensor* out) { +void CreateInferMeta(const IntArray& shape, DataType dtype, MetaTensor* out) { CreateInferMetaBase(shape.GetData(), dtype, DataLayout::NCHW, out); } @@ -48,7 +46,7 @@ void EyeInferMeta(int64_t num_rows, out->set_dtype(dtype); } -void GaussianRandomInferMeta(const ScalarArray& shape, +void GaussianRandomInferMeta(const IntArray& shape, float mean, float std, int seed, diff --git a/paddle/phi/infermeta/nullary.h b/paddle/phi/infermeta/nullary.h index d72e92654cdaaacaf8effe84fddde397baf1bcdb..4c9eb0b62a74e5373f003b17b80c5cf5876abee4 100644 --- a/paddle/phi/infermeta/nullary.h +++ b/paddle/phi/infermeta/nullary.h @@ -14,7 +14,7 @@ limitations under the License. */ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/meta_tensor.h" namespace phi { @@ -34,7 +34,7 @@ void AssignValueInferMeta(const std::vector& shape, DataType dtype, MetaTensor* out); -void CreateInferMeta(const ScalarArray& shape, DataType dtype, MetaTensor* out); +void CreateInferMeta(const IntArray& shape, DataType dtype, MetaTensor* out); void CreateInferMetaBase(const std::vector& shape, DataType dtype, @@ -46,7 +46,7 @@ void EyeInferMeta(int64_t num_rows, DataType dtype, MetaTensor* out); -void GaussianRandomInferMeta(const ScalarArray& shape, +void GaussianRandomInferMeta(const IntArray& shape, float mean, float std, int seed, diff --git a/paddle/phi/infermeta/strings/nullary.cc b/paddle/phi/infermeta/strings/nullary.cc index 807a5a9bf80a01a0831819f7e78b487ec9bfc541..c2428a2ff3ae9e7666c1cb09f9b4b2652463db4d 100644 --- a/paddle/phi/infermeta/strings/nullary.cc +++ b/paddle/phi/infermeta/strings/nullary.cc @@ -16,7 +16,7 @@ limitations under the License. */ namespace phi { namespace strings { -void CreateInferMeta(const ScalarArray& shape, MetaTensor* out) { +void CreateInferMeta(const IntArray& shape, MetaTensor* out) { const auto& out_dims = phi::make_ddim(shape.GetData()); out->set_dims(out_dims); out->set_dtype(DataType::PSTRING); diff --git a/paddle/phi/infermeta/strings/nullary.h b/paddle/phi/infermeta/strings/nullary.h index 513792ffff37d8c166d8cf0d2eb822423e4e6711..8fbcc63b2ae5d7cd1128b9c67ec5ac7672ce8564 100644 --- a/paddle/phi/infermeta/strings/nullary.h +++ b/paddle/phi/infermeta/strings/nullary.h @@ -14,7 +14,7 @@ limitations under the License. */ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/meta_tensor.h" #include "paddle/phi/core/tensor_meta.h" @@ -22,7 +22,7 @@ namespace phi { namespace strings { void CreateInferMeta(const std::vector& shape, MetaTensor* out); -void CreateInferMeta(const ScalarArray& shape, MetaTensor* out); +void CreateInferMeta(const IntArray& shape, MetaTensor* out); } // namespace strings } // namespace phi diff --git a/paddle/phi/infermeta/strings/unary.h b/paddle/phi/infermeta/strings/unary.h index fe942db6c9f3adb29790e117bcce366be2292b59..13b94ec1ace78b6daf161ab6574494f78fa185ac 100644 --- a/paddle/phi/infermeta/strings/unary.h +++ b/paddle/phi/infermeta/strings/unary.h @@ -15,7 +15,7 @@ limitations under the License. */ #pragma once // See Note [ Why still include the fluid headers? ] -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/core/meta_tensor.h" #include "paddle/phi/core/tensor_meta.h" diff --git a/paddle/phi/infermeta/unary.cc b/paddle/phi/infermeta/unary.cc index bbeb14363e84eaabe6486c27893a3b6c7a881d25..cb6ca34c1125b0b451fdd817c615d260b93ff510 100644 --- a/paddle/phi/infermeta/unary.cc +++ b/paddle/phi/infermeta/unary.cc @@ -1173,7 +1173,7 @@ void PadInferMeta(const MetaTensor& input, } void Pad3dInferMeta(const MetaTensor& x, - const ScalarArray& paddings_scalar_array, + const IntArray& paddings_int_array, const std::string& mode, float value, const std::string& data_format, @@ -1189,21 +1189,21 @@ void Pad3dInferMeta(const MetaTensor& x, std::vector out_dims(x_dim.size()); out_dims[0] = x_dim[0]; - if (paddings_scalar_array.FromTensor()) { + if (paddings_int_array.FromTensor()) { if (config.is_runtime) { PADDLE_ENFORCE_EQ( - paddings_scalar_array.GetData().size(), + paddings_int_array.GetData().size(), 6, errors::InvalidArgument("Shape of Input(Paddings) should be equal to " "[6], but received [%d].", - paddings_scalar_array.GetData().size())); + paddings_int_array.GetData().size())); } out_dims[1] = x_dim[1]; out_dims[2] = x_dim[2]; out_dims[3] = x_dim[3]; out_dims[4] = x_dim[4]; } else { - auto paddings = paddings_scalar_array.GetData(); + auto paddings = paddings_int_array.GetData(); PADDLE_ENFORCE_EQ( paddings.size(), @@ -1592,7 +1592,7 @@ void ReduceInferMetaBase(const MetaTensor& x, } void ReshapeInferMeta(const MetaTensor& x, - const ScalarArray& shape, + const IntArray& shape, MetaTensor* out, MetaConfig config) { auto& shape_data = shape.GetData(); @@ -1612,7 +1612,7 @@ void ReshapeInferMeta(const MetaTensor& x, } void ReshapeWithXShapeInferMeta(const MetaTensor& x, - const ScalarArray& shape, + const IntArray& shape, MetaTensor* out, MetaTensor* xshape, MetaConfig config) { @@ -1659,7 +1659,7 @@ void ReverseInferMeta(const MetaTensor& x, } void RollInferMeta(const MetaTensor& x, - const ScalarArray& shifts, + const IntArray& shifts, const std::vector& axis, MetaTensor* out) { auto shifts_data = shifts.GetData(); @@ -1758,7 +1758,7 @@ void SoftmaxInferMeta(const MetaTensor& x, int axis, MetaTensor* out) { } void SplitInferMeta(const MetaTensor& x, - const ScalarArray& num_or_sections, + const IntArray& num_or_sections, const Scalar& axis, std::vector out, MetaConfig config) { @@ -1924,9 +1924,9 @@ void SqueezeInferMeta(const MetaTensor& x, void StridedSliceInferMeta(const MetaTensor& x, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, MetaTensor* out, @@ -1968,7 +1968,7 @@ void StridedSliceInferMeta(const MetaTensor& x, } auto tensor_input = false; - auto HasInput = [](const ScalarArray& arr) { return arr.FromTensor(); }; + auto HasInput = [](const IntArray& arr) { return arr.FromTensor(); }; if (HasInput(starts) || HasInput(ends) || HasInput(strides)) { tensor_input = true; } @@ -2090,7 +2090,7 @@ void SumRawInferMeta(const MetaTensor& x, } void TileInferMeta(const MetaTensor& x, - const ScalarArray& repeat_times, + const IntArray& repeat_times, MetaTensor* out, MetaConfig config) { #define MAX_RANK_SUPPORTED 6 @@ -2553,7 +2553,7 @@ void UnfoldInferMeta(const MetaTensor& x, } void UnsqueezeInferMeta(const MetaTensor& x, - const ScalarArray& axes, + const IntArray& axes, MetaTensor* xshape, MetaTensor* out, MetaConfig config) { diff --git a/paddle/phi/infermeta/unary.h b/paddle/phi/infermeta/unary.h index ea902e0d98eca22df2b178c91e035016714d47f0..bef802727c288bdbef8dbf884caa095177798ef7 100644 --- a/paddle/phi/infermeta/unary.h +++ b/paddle/phi/infermeta/unary.h @@ -15,8 +15,8 @@ limitations under the License. */ #pragma once // See Note [ Why still include the fluid headers? ] +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/meta_tensor.h" namespace phi { @@ -185,7 +185,7 @@ void PadInferMeta(const MetaTensor& input, MetaConfig config = MetaConfig()); void Pad3dInferMeta(const MetaTensor& x, - const ScalarArray& paddings, + const IntArray& paddings, const std::string& mode, float value, const std::string& data_format, @@ -238,12 +238,12 @@ void ReduceInferMetaBase(const MetaTensor& x, MetaTensor* out); void ReshapeInferMeta(const MetaTensor& x, - const ScalarArray& shape, + const IntArray& shape, MetaTensor* out, MetaConfig config = MetaConfig()); void ReshapeWithXShapeInferMeta(const MetaTensor& x, - const ScalarArray& shape, + const IntArray& shape, MetaTensor* out, MetaTensor* xshape, MetaConfig config = MetaConfig()); @@ -253,7 +253,7 @@ void ReverseInferMeta(const MetaTensor& x, MetaTensor* out); void RollInferMeta(const MetaTensor& x, - const ScalarArray& shifts, + const IntArray& shifts, const std::vector& axis, MetaTensor* out); @@ -274,7 +274,7 @@ void SizeInferMeta(const MetaTensor& input, MetaTensor* out); void SoftmaxInferMeta(const MetaTensor& x, int axis, MetaTensor* out); void SplitInferMeta(const MetaTensor& x_meta, - const ScalarArray& num_or_sections, + const IntArray& num_or_sections, const Scalar& axis, std::vector out, MetaConfig config = MetaConfig()); @@ -286,9 +286,9 @@ void SqueezeInferMeta(const MetaTensor& x, void StridedSliceInferMeta(const MetaTensor& x, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, MetaTensor* out, @@ -308,7 +308,7 @@ void SumRawInferMeta(const MetaTensor& x, MetaTensor* out); void TileInferMeta(const MetaTensor& x, - const ScalarArray& repeat_times, + const IntArray& repeat_times, MetaTensor* out, MetaConfig config = MetaConfig()); @@ -361,7 +361,7 @@ void UnfoldInferMeta(const MetaTensor& x, MetaConfig config = MetaConfig()); void UnsqueezeInferMeta(const MetaTensor& x, - const ScalarArray& axes, + const IntArray& axes, MetaTensor* xshape, MetaTensor* out, MetaConfig config = MetaConfig()); diff --git a/paddle/phi/kernels/cpu/full_kernel.cc b/paddle/phi/kernels/cpu/full_kernel.cc index 556de3adcf498a111bcaad2f5b849bfe79be8adf..0b76425a659a0ef51a94e0c8d2b769a5e25cd957 100644 --- a/paddle/phi/kernels/cpu/full_kernel.cc +++ b/paddle/phi/kernels/cpu/full_kernel.cc @@ -31,7 +31,7 @@ void FullValue(const Context& dev_ctx, DenseTensor* tensor, VType val) { template void FullKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, const Scalar& val, DataType dtype, DenseTensor* out) { diff --git a/paddle/phi/kernels/cpu/gaussian_random_kernel.cc b/paddle/phi/kernels/cpu/gaussian_random_kernel.cc index 7e336f18bf80a36d1c954533aa7dc2534c4f7f2c..348d24b534e3e22758de4e2c564796cd494ca1f8 100644 --- a/paddle/phi/kernels/cpu/gaussian_random_kernel.cc +++ b/paddle/phi/kernels/cpu/gaussian_random_kernel.cc @@ -23,7 +23,7 @@ namespace phi { template void GaussianRandomKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, float mean, float std, int seed, diff --git a/paddle/phi/kernels/cpu/pad3d_grad_kernel.cc b/paddle/phi/kernels/cpu/pad3d_grad_kernel.cc index b1adb3e206da97918dc69ee4694de1be525b382e..1b73acfa015096a044dfcb64612be86cfee174c9 100644 --- a/paddle/phi/kernels/cpu/pad3d_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/pad3d_grad_kernel.cc @@ -362,7 +362,7 @@ template void Pad3dGradKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, - const ScalarArray& paddings, + const IntArray& paddings, const std::string& mode, float pad_value, const std::string& data_format, diff --git a/paddle/phi/kernels/cpu/pad3d_kernel.cc b/paddle/phi/kernels/cpu/pad3d_kernel.cc index 68bd92168364d927455e86eb736a2134b2bff6af..aa44491a2a967d75ad412247aeaa8a64049c8e76 100644 --- a/paddle/phi/kernels/cpu/pad3d_kernel.cc +++ b/paddle/phi/kernels/cpu/pad3d_kernel.cc @@ -379,7 +379,7 @@ void Pad3DNDHWC(const T* in_data, template void Pad3dKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& paddings, + const IntArray& paddings, const std::string& mode, float pad_value, const std::string& data_format, diff --git a/paddle/phi/kernels/cpu/randint_kernel.cc b/paddle/phi/kernels/cpu/randint_kernel.cc index feb418949ba40d3bf553c2df0b4300cc686a0ef7..2c7433f5d210046e39901a59489955b2358c5095 100644 --- a/paddle/phi/kernels/cpu/randint_kernel.cc +++ b/paddle/phi/kernels/cpu/randint_kernel.cc @@ -25,7 +25,7 @@ template void RandintRawKernel(const Context& dev_ctx, int low, int high, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, int seed, DenseTensor* out) { @@ -49,7 +49,7 @@ template void RandintKernel(const Context& dev_ctx, int low, int high, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, DenseTensor* out) { RandintRawKernel(dev_ctx, low, high, shape, dtype, 0, out); diff --git a/paddle/phi/kernels/cpu/roll_grad_kernel.cc b/paddle/phi/kernels/cpu/roll_grad_kernel.cc index b0d0c0663e4a2eb71f4500baaf43bc8a891acddd..b3bd27fca12a64a0029ff518dd0000003187b85f 100644 --- a/paddle/phi/kernels/cpu/roll_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/roll_grad_kernel.cc @@ -24,7 +24,7 @@ template void RollGradKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, - const ScalarArray& shifts, + const IntArray& shifts, const std::vector& axis, DenseTensor* x_grad) { std::vector out_vec; diff --git a/paddle/phi/kernels/cpu/roll_kernel.cc b/paddle/phi/kernels/cpu/roll_kernel.cc index 25b64ef257dfb801f0050aad388b9fb0b3020ea5..67eb80304de58781426cd96061ab23191238db06 100644 --- a/paddle/phi/kernels/cpu/roll_kernel.cc +++ b/paddle/phi/kernels/cpu/roll_kernel.cc @@ -25,7 +25,7 @@ namespace phi { template void RollKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& shifts, + const IntArray& shifts, const std::vector& axis, DenseTensor* out) { std::vector out_vec; diff --git a/paddle/phi/kernels/cpu/roll_kernel_impl.h b/paddle/phi/kernels/cpu/roll_kernel_impl.h index 924e71aff31f3f874fb35586f496b9c5952c3757..e2d96b896ac6a61a41d1d8ea12777dd661ae46ad 100644 --- a/paddle/phi/kernels/cpu/roll_kernel_impl.h +++ b/paddle/phi/kernels/cpu/roll_kernel_impl.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/split_kernel.cc b/paddle/phi/kernels/cpu/split_kernel.cc index ea8e2702c19d6edd9f63d1da647db0ef07a417f1..56d872922490aa02be954f8048e8ed042dbc83ae 100644 --- a/paddle/phi/kernels/cpu/split_kernel.cc +++ b/paddle/phi/kernels/cpu/split_kernel.cc @@ -25,7 +25,7 @@ namespace phi { template void SplitKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& num_or_sections, + const IntArray& num_or_sections, const Scalar& axis_scalar, std::vector outs) { // need to infershape output diff --git a/paddle/phi/kernels/cpu/triangular_solve_kernel.cc b/paddle/phi/kernels/cpu/triangular_solve_kernel.cc index c91e7475f5b7c4ea7c420eb72cccd8cd82b0aa0c..f2af19792615c5df244cafa69a697382e5348f49 100644 --- a/paddle/phi/kernels/cpu/triangular_solve_kernel.cc +++ b/paddle/phi/kernels/cpu/triangular_solve_kernel.cc @@ -41,14 +41,14 @@ void TriangularSolveKernel(const Context& dev_ctx, int y_bst_ndim = y_bst_dims_vec.size(); // Tensor broadcast to 'out' and temp 'x_bst' - ScalarArray x_bst_dims(x_bst_dims_vec); + IntArray x_bst_dims(x_bst_dims_vec); DenseTensor x_bst = phi::Empty(dev_ctx, x_bst_dims); const T* x_bst_data = x_bst.data(); ExpandKernel(dev_ctx, x, x_bst_dims, &x_bst); out->Resize(phi::make_ddim(y_bst_dims_vec)); T* out_data = dev_ctx.template Alloc(out); - ScalarArray y_bst_dims(y_bst_dims_vec); + IntArray y_bst_dims(y_bst_dims_vec); ExpandKernel(dev_ctx, y, y_bst_dims, out); // Calculate use blas library diff --git a/paddle/phi/kernels/cpu/uniform_random_kernel.cc b/paddle/phi/kernels/cpu/uniform_random_kernel.cc index 8ec1d9683e15a92c7184d91005f85258cf1dd004..91a6903418230755e5777067f26b841ce39f61d5 100644 --- a/paddle/phi/kernels/cpu/uniform_random_kernel.cc +++ b/paddle/phi/kernels/cpu/uniform_random_kernel.cc @@ -44,7 +44,7 @@ inline void UniformRealDistribution(phi::dtype::bfloat16 *data, template void UniformRandomRawKernel(const Context &dev_ctx, - const ScalarArray &shape, + const IntArray &shape, DataType dtype, float min, float max, @@ -86,7 +86,7 @@ void UniformRandomRawKernel(const Context &dev_ctx, template void UniformRandomKernel(const Context &dev_ctx, - const ScalarArray &shape, + const IntArray &shape, DataType dtype, float min, float max, diff --git a/paddle/phi/kernels/empty_kernel.cc b/paddle/phi/kernels/empty_kernel.cc index 6e5f15fe1692b473965f96f68fd86fad87f1892e..e547e0ea1318d7e0047b0aee940bae8a5341713e 100644 --- a/paddle/phi/kernels/empty_kernel.cc +++ b/paddle/phi/kernels/empty_kernel.cc @@ -22,7 +22,7 @@ namespace phi { template void EmptyKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, DenseTensor* out) { out->Resize(phi::make_ddim(shape.GetData())); diff --git a/paddle/phi/kernels/empty_kernel.h b/paddle/phi/kernels/empty_kernel.h index f66f4419fd7f5853565d561751d793b8f10c9b46..163179e578d9a39e9df34b3551eafc6777168f79 100644 --- a/paddle/phi/kernels/empty_kernel.h +++ b/paddle/phi/kernels/empty_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/device_context.h" #include "paddle/phi/infermeta/nullary.h" @@ -24,7 +24,7 @@ namespace phi { template void EmptyKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, DenseTensor* out); @@ -43,7 +43,7 @@ DenseTensor Empty(const Context& dev_ctx, DenseTensorMeta&& meta) { } template -DenseTensor Empty(const Context& dev_ctx, const ScalarArray& shape) { +DenseTensor Empty(const Context& dev_ctx, const IntArray& shape) { DenseTensor dense_out; MetaTensor meta_out(&dense_out); DataType dtype = paddle::experimental::CppTypeToDataType::Type(); diff --git a/paddle/phi/kernels/expand_grad_kernel.h b/paddle/phi/kernels/expand_grad_kernel.h index d35b4b663e0fe2d6c966a5b60f23662caaed21e0..a734498b9870df182c2b483a224f8a32e48142a6 100644 --- a/paddle/phi/kernels/expand_grad_kernel.h +++ b/paddle/phi/kernels/expand_grad_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/device_context.h" @@ -24,7 +24,7 @@ template void ExpandGradKernel(const Context& ctx, const DenseTensor& x, const DenseTensor& out_grad, - const ScalarArray& shape, + const IntArray& shape, DenseTensor* in_grad); } // namespace phi diff --git a/paddle/phi/kernels/expand_kernel.h b/paddle/phi/kernels/expand_kernel.h index fb5a0112ffcf7120314471db3c30b0e72a2b9c81..3b44c46e4dd7c77c1cd50d43745911b68a17e9f1 100644 --- a/paddle/phi/kernels/expand_kernel.h +++ b/paddle/phi/kernels/expand_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/device_context.h" @@ -23,7 +23,7 @@ namespace phi { template void ExpandKernel(const Context& ctx, const DenseTensor& x, - const ScalarArray& shape, + const IntArray& shape, DenseTensor* out); } // namepsace phi diff --git a/paddle/phi/kernels/full_kernel.h b/paddle/phi/kernels/full_kernel.h index df82e651a0b268cba49d64dff6307d41a377fe0a..d5785f2eedafa187621c1965f6e14ec57fff0c85 100644 --- a/paddle/phi/kernels/full_kernel.h +++ b/paddle/phi/kernels/full_kernel.h @@ -16,8 +16,8 @@ #include +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/infermeta/nullary.h" @@ -27,7 +27,7 @@ namespace phi { template void FullKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, const Scalar& val, DataType dtype, DenseTensor* out); @@ -53,7 +53,7 @@ void FullBatchSizeLikeKernel(const Context& dev_ctx, template void Full(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, const Scalar& val, DenseTensor* out) { FullKernel(dev_ctx, @@ -65,7 +65,7 @@ void Full(const Context& dev_ctx, template DenseTensor Full(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, const Scalar& val) { DenseTensor dense_out; MetaTensor meta_out(&dense_out); diff --git a/paddle/phi/kernels/funcs/select_impl.cu.h b/paddle/phi/kernels/funcs/select_impl.cu.h index 16e00414ad772a162d33fb18c0dfafc889e53951..193b9f614c9d5463155ada6707ddd0298b19dc34 100644 --- a/paddle/phi/kernels/funcs/select_impl.cu.h +++ b/paddle/phi/kernels/funcs/select_impl.cu.h @@ -414,7 +414,7 @@ void SelectKernel(const KPDevice &dev_ctx, // 1.2 alloc tmp data for CoutBlock const int size_count_block = need_grids + 1; std::vector dims_vec = {size_count_block * 2}; - ScalarArray dims_array(dims_vec); + IntArray dims_array(dims_vec); DenseTensor count_mem = phi::Empty(dev_ctx, dims_array); CT *count_data = count_mem.data(); // 1.3 launch CountKernl diff --git a/paddle/phi/kernels/funcs/strided_slice.h b/paddle/phi/kernels/funcs/strided_slice.h index 38a611ba26e229fb19e861adf77832a12ab4bc72..8eebfc7caa79536f5fe8d74f739da9eb948bece8 100644 --- a/paddle/phi/kernels/funcs/strided_slice.h +++ b/paddle/phi/kernels/funcs/strided_slice.h @@ -178,9 +178,9 @@ template void StridedSliceCompute(const Context& dev_ctx, const DenseTensor& x, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* out) { @@ -295,9 +295,9 @@ template void StridedSliceCompute(const Context& dev_ctx, const std::vector& x, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, std::vector out) { @@ -446,9 +446,9 @@ void StridedSliceGradCompute(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* x_grad) { @@ -530,9 +530,9 @@ void StridedSliceGradCompute(const Context& dev_ctx, const std::vector& x, const std::vector& out_grad, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, std::vector x_grad) { diff --git a/paddle/phi/kernels/gaussian_random_kernel.h b/paddle/phi/kernels/gaussian_random_kernel.h index 2903d80d22d46bcdc492009afdac4e6e6572929e..7424ad484a1fdde61912210b83aad31605e82615 100644 --- a/paddle/phi/kernels/gaussian_random_kernel.h +++ b/paddle/phi/kernels/gaussian_random_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/device_context.h" @@ -22,7 +22,7 @@ namespace phi { template void GaussianRandomKernel(const Context& ctx, - const ScalarArray& shape, + const IntArray& shape, float mean, float std, int seed, diff --git a/paddle/phi/kernels/gpu/full_kernel.cu b/paddle/phi/kernels/gpu/full_kernel.cu index 852d209ee018598285b3dff35ffd51e289f07976..79b71b95d9ee81320061832edca481d3e2ce65ef 100644 --- a/paddle/phi/kernels/gpu/full_kernel.cu +++ b/paddle/phi/kernels/gpu/full_kernel.cu @@ -35,7 +35,7 @@ struct FullFuctor { template void FullKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, const Scalar& val, DataType dtype, DenseTensor* out) { diff --git a/paddle/phi/kernels/gpu/gaussian_random_kernel.cu b/paddle/phi/kernels/gpu/gaussian_random_kernel.cu index e2fe2190c1ce0cebea1326e70ce8572ff9bc4d88..e159e5916cff2b602e0638e3fa01d1126598381d 100644 --- a/paddle/phi/kernels/gpu/gaussian_random_kernel.cu +++ b/paddle/phi/kernels/gpu/gaussian_random_kernel.cu @@ -58,7 +58,7 @@ struct GaussianGenerator { template void GaussianRandomKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, float mean, float std, int seed, diff --git a/paddle/phi/kernels/gpu/multinomial_kernel.cu b/paddle/phi/kernels/gpu/multinomial_kernel.cu index 752a91fa48198c305763d66c0dbf8d2c9f2fa307..ee5f843b18a90aa9b2750d0e4beec2fefd462ebf 100644 --- a/paddle/phi/kernels/gpu/multinomial_kernel.cu +++ b/paddle/phi/kernels/gpu/multinomial_kernel.cu @@ -243,8 +243,7 @@ void MultinomialKernel(const Context& dev_ctx, dev_ctx, rand, -1, true, false, 3 /*proto::VarType::INT64*/, out); } else { std::vector out_dim_vec = vectorize(out->dims()); - DenseTensor value = - Empty(dev_ctx, ScalarArray(out_dim_vec)); + DenseTensor value = Empty(dev_ctx, IntArray(out_dim_vec)); TopkKernel( dev_ctx, rand, Scalar(num_samples), -1, true, true, &value, out); } diff --git a/paddle/phi/kernels/gpu/pad3d_grad_kernel.cu b/paddle/phi/kernels/gpu/pad3d_grad_kernel.cu index 5ca8f3d73daded476052b77459bd68f2184ab290..8f4af0a450890004bd09a650280583da8b961b95 100644 --- a/paddle/phi/kernels/gpu/pad3d_grad_kernel.cu +++ b/paddle/phi/kernels/gpu/pad3d_grad_kernel.cu @@ -330,7 +330,7 @@ template void Pad3dGradKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, - const ScalarArray& paddings, + const IntArray& paddings, const std::string& mode, float pad_value, const std::string& data_format, diff --git a/paddle/phi/kernels/gpu/pad3d_kernel.cu b/paddle/phi/kernels/gpu/pad3d_kernel.cu index 8f7cf716e79cf70c4e99274383e8623dd039c47d..d1b1d70667673e76de93711643490c5465d4bbb9 100644 --- a/paddle/phi/kernels/gpu/pad3d_kernel.cu +++ b/paddle/phi/kernels/gpu/pad3d_kernel.cu @@ -327,7 +327,7 @@ __global__ void Pad3DCircularNDHWC(const int nthreads, template void Pad3dKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& paddings, + const IntArray& paddings, const std::string& mode, float pad_value, const std::string& data_format, diff --git a/paddle/phi/kernels/gpu/randint_kernel.cu b/paddle/phi/kernels/gpu/randint_kernel.cu index d4cbd5c73feae26b04ff6c73f505f1b60a80138d..018850500226885bb7982341a97ac1793e6fefca 100644 --- a/paddle/phi/kernels/gpu/randint_kernel.cu +++ b/paddle/phi/kernels/gpu/randint_kernel.cu @@ -31,7 +31,7 @@ template void RandintRawKernel(const Context& dev_ctx, int low, int high, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, int seed, DenseTensor* out) { @@ -74,7 +74,7 @@ template void RandintKernel(const Context& dev_ctx, int low, int high, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, DenseTensor* out) { RandintRawKernel(dev_ctx, low, high, shape, dtype, 0, out); diff --git a/paddle/phi/kernels/gpu/randperm_kernel.cu b/paddle/phi/kernels/gpu/randperm_kernel.cu index 92948bf47c9345e53d1fea54d2be4fd8efbc6f96..678b580beca2f6515198fd4a4a126cda645d4660 100644 --- a/paddle/phi/kernels/gpu/randperm_kernel.cu +++ b/paddle/phi/kernels/gpu/randperm_kernel.cu @@ -89,12 +89,12 @@ void RandpermRawKernel( RandintKernel(dev_ctx, std::numeric_limits::min(), std::numeric_limits::max(), - ScalarArray({n}), + IntArray({n}), phi::DataType::INT32, &key); - DenseTensor key_out = Empty(dev_ctx, ScalarArray({n})); + DenseTensor key_out = Empty(dev_ctx, IntArray({n})); - DenseTensor range = Empty(dev_ctx, ScalarArray({n})); + DenseTensor range = Empty(dev_ctx, IntArray({n})); T* range_data = range.data(); funcs::ForRange for_range(dev_ctx, n); for_range([range_data] __device__(size_t idx) { diff --git a/paddle/phi/kernels/gpu/roll_grad_kernel.cu b/paddle/phi/kernels/gpu/roll_grad_kernel.cu index 93e9e81882c9e6eacd5f9ee91fa7541495ef2663..82e0fa72ab07607445e15b20822ba996a2269bd1 100644 --- a/paddle/phi/kernels/gpu/roll_grad_kernel.cu +++ b/paddle/phi/kernels/gpu/roll_grad_kernel.cu @@ -26,7 +26,7 @@ template void RollGradKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, - const ScalarArray& shifts, + const IntArray& shifts, const std::vector& axis, DenseTensor* x_grad) { auto* in_data = out_grad.data(); diff --git a/paddle/phi/kernels/gpu/roll_kernel.cu b/paddle/phi/kernels/gpu/roll_kernel.cu index 1543335d3a0c5884d6b82394253bb4e8dda8cef0..5d3584e4f44c1e68bc2ab4d6ff7b0ada39477a34 100644 --- a/paddle/phi/kernels/gpu/roll_kernel.cu +++ b/paddle/phi/kernels/gpu/roll_kernel.cu @@ -26,7 +26,7 @@ using paddle::platform::PADDLE_CUDA_NUM_THREADS; template void RollKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& shifts, + const IntArray& shifts, const std::vector& axis, DenseTensor* out) { auto* in_data = x.data(); diff --git a/paddle/phi/kernels/gpu/split_kernel.cu b/paddle/phi/kernels/gpu/split_kernel.cu index 83c2ec4b6e99d675bfbcab58abd265cc8595259c..73b64ce9703190d56948eba1487223c5784f7942 100644 --- a/paddle/phi/kernels/gpu/split_kernel.cu +++ b/paddle/phi/kernels/gpu/split_kernel.cu @@ -24,7 +24,7 @@ namespace phi { template void SplitKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& num_or_sections, + const IntArray& num_or_sections, const Scalar& axis_scalar, std::vector outs) { // need to infershape output diff --git a/paddle/phi/kernels/gpu/triangular_solve_kernel.cu b/paddle/phi/kernels/gpu/triangular_solve_kernel.cu index f137d8e1c260387686cbf3d0fbadf686d9e13019..a48afeb2c796b70b24059a1cb87f1a1a3d665b35 100644 --- a/paddle/phi/kernels/gpu/triangular_solve_kernel.cu +++ b/paddle/phi/kernels/gpu/triangular_solve_kernel.cu @@ -45,14 +45,14 @@ void TriangularSolveKernel(const Context& dev_ctx, int y_bst_ndim = y_bst_dims_vec.size(); // Tensor broadcast to 'out' and temp 'x_bst' - ScalarArray x_bst_dims(x_bst_dims_vec); + IntArray x_bst_dims(x_bst_dims_vec); DenseTensor x_bst = phi::Empty(dev_ctx, x_bst_dims); const T* x_bst_data = x_bst.data(); ExpandKernel(dev_ctx, x, x_bst_dims, &x_bst); out->Resize(phi::make_ddim(y_bst_dims_vec)); T* out_data = dev_ctx.template Alloc(out); - ScalarArray y_bst_dims(y_bst_dims_vec); + IntArray y_bst_dims(y_bst_dims_vec); ExpandKernel(dev_ctx, y, y_bst_dims, out); // calculate use cublas library diff --git a/paddle/phi/kernels/gpu/uniform_random_kernel.cu b/paddle/phi/kernels/gpu/uniform_random_kernel.cu index cdab9faf6aafe35045060a011e1354c11a4c9375..2cabde0bbf9425331d36379a86929143aa2094df 100644 --- a/paddle/phi/kernels/gpu/uniform_random_kernel.cu +++ b/paddle/phi/kernels/gpu/uniform_random_kernel.cu @@ -93,7 +93,7 @@ struct UniformGeneratorOffset { template void UniformRandomRawKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, float min, float max, @@ -140,7 +140,7 @@ void UniformRandomRawKernel(const Context& dev_ctx, template void UniformRandomKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, float min, float max, diff --git a/paddle/phi/kernels/impl/cholesky_solve_grad_kernel_impl.h b/paddle/phi/kernels/impl/cholesky_solve_grad_kernel_impl.h index e3ea10705d24e90a76246d439c6d9263e072bc39..8c37091ef1b54def8ef81161a4ac0a85fc265967 100644 --- a/paddle/phi/kernels/impl/cholesky_solve_grad_kernel_impl.h +++ b/paddle/phi/kernels/impl/cholesky_solve_grad_kernel_impl.h @@ -46,8 +46,8 @@ void CholeskySolveGradKernel(const Context& dev_ctx, std::vector y_bst_dims_vec; std::tie(x_bst_dims_vec, y_bst_dims_vec) = funcs::MatrixGetBroadcastDims(x, y); - ScalarArray x_bst_dims(x_bst_dims_vec); - ScalarArray y_bst_dims(y_bst_dims_vec); + IntArray x_bst_dims(x_bst_dims_vec); + IntArray y_bst_dims(y_bst_dims_vec); // Tensor broadcast to temp 'y_bst' DenseTensor y_bst = phi::Empty(dev_ctx, y_bst_dims); diff --git a/paddle/phi/kernels/impl/cholesky_solve_kernel_impl.h b/paddle/phi/kernels/impl/cholesky_solve_kernel_impl.h index 16ceb776f1a98a0a7050d6cc9f3ec17be7bb617f..c039d11635ba2f29c0130f99b8fc3c8fd59582dd 100644 --- a/paddle/phi/kernels/impl/cholesky_solve_kernel_impl.h +++ b/paddle/phi/kernels/impl/cholesky_solve_kernel_impl.h @@ -49,8 +49,8 @@ void CholeskySolveKernel(const Context& dev_ctx, std::vector y_bst_dims_vec; std::tie(x_bst_dims_vec, y_bst_dims_vec) = funcs::MatrixGetBroadcastDims(x, y); - ScalarArray x_bst_dims(x_bst_dims_vec); - ScalarArray y_bst_dims(y_bst_dims_vec); + IntArray x_bst_dims(x_bst_dims_vec); + IntArray y_bst_dims(y_bst_dims_vec); DenseTensor y_bst = phi::Empty(dev_ctx, y_bst_dims); ExpandKernel(dev_ctx, y, y_bst_dims, &y_bst); @@ -79,8 +79,7 @@ void CholeskySolveKernel(const Context& dev_ctx, int N = static_cast(x_bst_dims_vec[x_bst_ndim - 1]); int batchsize = product(phi::slice_ddim(x_bst.dims(), 0, x_bst_ndim - 2)); - DenseTensor info = - phi::Empty(dev_ctx, ScalarArray({batchsize})); + DenseTensor info = phi::Empty(dev_ctx, IntArray({batchsize})); int* info_data = info.data(); CholeskySolveFunctor functor; diff --git a/paddle/phi/kernels/impl/expand_grad_kernel_impl.h b/paddle/phi/kernels/impl/expand_grad_kernel_impl.h index 766f91cd22e1f4584708c506b0ef5f742fdc366e..a4fc7157eeaf8196bbae0fb3d849e3fe4c775f66 100644 --- a/paddle/phi/kernels/impl/expand_grad_kernel_impl.h +++ b/paddle/phi/kernels/impl/expand_grad_kernel_impl.h @@ -50,7 +50,7 @@ template void ExpandGradKernel(const Context& ctx, const DenseTensor& x, const DenseTensor& out_grad, - const ScalarArray& shape, + const IntArray& shape, DenseTensor* in_grad) { auto expand_shape = shape.GetData(); auto x_dims = x.dims(); diff --git a/paddle/phi/kernels/impl/expand_kernel_impl.h b/paddle/phi/kernels/impl/expand_kernel_impl.h index 4d287771be297692e5c67edf244dbdc40ad0c4e8..54fd1100ab332c0ed783ed6f1527c4dafec429e1 100644 --- a/paddle/phi/kernels/impl/expand_kernel_impl.h +++ b/paddle/phi/kernels/impl/expand_kernel_impl.h @@ -27,7 +27,7 @@ using Tensor = DenseTensor; template void Expand(const Context& ctx, const DenseTensor& x, - const ScalarArray& shape, + const IntArray& shape, DenseTensor* out) { auto in_dims = x.dims(); auto expand_shape = shape.GetData(); @@ -107,7 +107,7 @@ void Expand(const Context& ctx, template void ExpandKernel(const Context& ctx, const DenseTensor& x, - const ScalarArray& shape, + const IntArray& shape, DenseTensor* out) { auto rank = x.dims().size(); PADDLE_ENFORCE_GE( diff --git a/paddle/phi/kernels/impl/set_value_grad_kernel_impl.h b/paddle/phi/kernels/impl/set_value_grad_kernel_impl.h index 0e39c0a726bf4c68fc298ea4af098e59bf3da1c1..96660c7084be61385d59a6d4ec9c4043e045447d 100644 --- a/paddle/phi/kernels/impl/set_value_grad_kernel_impl.h +++ b/paddle/phi/kernels/impl/set_value_grad_kernel_impl.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/kernels/copy_kernel.h" @@ -48,9 +48,9 @@ inline void GetOffsets(const DDim& big_dim, template void SetValueGradImpl(const Context& dev_ctx, const DenseTensor& out_grad, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& steps, + const IntArray& starts, + const IntArray& ends, + const IntArray& steps, const std::vector& axes, const std::vector& decrease_axes, const std::vector& none_axes, @@ -249,9 +249,9 @@ void SetValueGradImpl(const Context& dev_ctx, template void SetValueGradKernel(const Context& dev_ctx, const DenseTensor& out_grad, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& steps, + const IntArray& starts, + const IntArray& ends, + const IntArray& steps, const std::vector& axes, const std::vector& decrease_axes, const std::vector& none_axes, diff --git a/paddle/phi/kernels/impl/set_value_kernel_impl.h b/paddle/phi/kernels/impl/set_value_kernel_impl.h index cbe94efb439084744ddd9baacd0c310346ce9ab2..229dcf671f99311c50025282b0c5e444279b51b4 100644 --- a/paddle/phi/kernels/impl/set_value_kernel_impl.h +++ b/paddle/phi/kernels/impl/set_value_kernel_impl.h @@ -14,8 +14,8 @@ #pragma once +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/kernels/copy_kernel.h" @@ -73,9 +73,9 @@ template void SetValueImpl(const Context& dev_ctx, const DenseTensor& in, const DenseTensor& value, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& steps, + const IntArray& starts, + const IntArray& ends, + const IntArray& steps, const std::vector& axes, const std::vector& decrease_axes, const std::vector& none_axes, @@ -134,9 +134,9 @@ void SetValueImpl(const Context& dev_ctx, Copy(dev_ctx, in, place, false, out); DenseTensor slice_tensor = - Empty(dev_ctx, ScalarArray{slice_dims.Get(), slice_dims.size()}); + Empty(dev_ctx, IntArray{slice_dims.Get(), slice_dims.size()}); DenseTensor pad_tensor = - Empty(dev_ctx, ScalarArray{in_dims.Get(), in_dims.size()}); + Empty(dev_ctx, IntArray{in_dims.Get(), in_dims.size()}); auto pad_e = EigenTensor::From(pad_tensor, in_dims); auto out_e = EigenTensor::From(*out); @@ -211,9 +211,9 @@ template void SetTensorValueKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& value, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& steps, + const IntArray& starts, + const IntArray& ends, + const IntArray& steps, const std::vector& axes, const std::vector& decrease_axes, const std::vector& none_axes, @@ -302,9 +302,9 @@ void SetTensorValueKernel(const Context& dev_ctx, template void SetValueKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& steps, + const IntArray& starts, + const IntArray& ends, + const IntArray& steps, const std::vector& axes, const std::vector& decrease_axes, const std::vector& none_axes, diff --git a/paddle/phi/kernels/impl/slice_grad_kernel_impl.h b/paddle/phi/kernels/impl/slice_grad_kernel_impl.h index 1dbb5bd142c52785605967a8f7a3b39c2967dbd1..a5c67a32553c96fb3d3e720d726aaba505e1fd6f 100644 --- a/paddle/phi/kernels/impl/slice_grad_kernel_impl.h +++ b/paddle/phi/kernels/impl/slice_grad_kernel_impl.h @@ -274,8 +274,8 @@ void SliceGradRawKernel(const Context& ctx, const DenseTensor& input, const DenseTensor& out_grad, const std::vector& axes, - const ScalarArray& starts_arr, - const ScalarArray& ends_arr, + const IntArray& starts_arr, + const IntArray& ends_arr, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* input_grad) { diff --git a/paddle/phi/kernels/impl/slice_kernel_impl.h b/paddle/phi/kernels/impl/slice_kernel_impl.h index 5c127358e8eeef6bdbeddc3609670361142f6f89..b855ef43aa7eee8be019b9672060128c699053fb 100644 --- a/paddle/phi/kernels/impl/slice_kernel_impl.h +++ b/paddle/phi/kernels/impl/slice_kernel_impl.h @@ -110,8 +110,8 @@ template void SliceRawKernel(const Context& ctx, const DenseTensor& input, const std::vector& axes, - const ScalarArray& starts_arr, - const ScalarArray& ends_arr, + const IntArray& starts_arr, + const IntArray& ends_arr, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* out) { diff --git a/paddle/phi/kernels/impl/strided_slice_grad_kernel_impl.h b/paddle/phi/kernels/impl/strided_slice_grad_kernel_impl.h index 1d75b32a5f21db59923a8352d39ef09f9649d6b1..f0fddce6b55472f8afe03579b3bf5b1ca7b93afe 100644 --- a/paddle/phi/kernels/impl/strided_slice_grad_kernel_impl.h +++ b/paddle/phi/kernels/impl/strided_slice_grad_kernel_impl.h @@ -24,9 +24,9 @@ void StridedSliceGradKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* x_grad) { @@ -62,9 +62,9 @@ void StridedSliceArrayGradKernel( const std::vector& x, const std::vector& out_grad, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, std::vector x_grad) { diff --git a/paddle/phi/kernels/impl/strided_slice_kernel_impl.h b/paddle/phi/kernels/impl/strided_slice_kernel_impl.h index f98ac1aedcf17ef63ec6e20d46f835d778318218..2df937524ef20109a22c8ba00b93ebd00d58e7a1 100644 --- a/paddle/phi/kernels/impl/strided_slice_kernel_impl.h +++ b/paddle/phi/kernels/impl/strided_slice_kernel_impl.h @@ -23,9 +23,9 @@ template void StridedSliceKernel(const Context& dev_ctx, const DenseTensor& x, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* out) { @@ -58,9 +58,9 @@ template void StridedSliceArrayKernel(const Context& dev_ctx, const std::vector& x, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, std::vector out) { diff --git a/paddle/phi/kernels/impl/tile_grad_kernel_impl.h b/paddle/phi/kernels/impl/tile_grad_kernel_impl.h index b373855eee50ade90ca675ea91967466884678bb..9e56e50534d19bec29b6ee9fdc05ae4a1210dd41 100644 --- a/paddle/phi/kernels/impl/tile_grad_kernel_impl.h +++ b/paddle/phi/kernels/impl/tile_grad_kernel_impl.h @@ -53,7 +53,7 @@ template void TileGradKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, - const ScalarArray& repeat_times, + const IntArray& repeat_times, DenseTensor* x_grad) { auto x_dims = x.dims(); auto vec_x_dims = phi::vectorize(x_dims); diff --git a/paddle/phi/kernels/impl/tile_kernel_impl.h b/paddle/phi/kernels/impl/tile_kernel_impl.h index bafbbde4e680daa04a62ba9ab6b03778b4477107..d19a6a7800671f160fb76863b8eedbf82d4af64d 100644 --- a/paddle/phi/kernels/impl/tile_kernel_impl.h +++ b/paddle/phi/kernels/impl/tile_kernel_impl.h @@ -85,7 +85,7 @@ void Tile(const Context& dev_ctx, template void TileKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& repeat_times, + const IntArray& repeat_times, DenseTensor* out) { auto rank = x.dims().size(); auto& repeat_times_data = repeat_times.GetData(); diff --git a/paddle/phi/kernels/impl/triangular_solve_grad_kernel_impl.h b/paddle/phi/kernels/impl/triangular_solve_grad_kernel_impl.h index 044adb0230cac4d0dc6bf9e9348968e4d7c60b5d..30f2d5a05cdc0f7918c42f5b4446caa8967404c1 100644 --- a/paddle/phi/kernels/impl/triangular_solve_grad_kernel_impl.h +++ b/paddle/phi/kernels/impl/triangular_solve_grad_kernel_impl.h @@ -44,7 +44,7 @@ void TriangularSolveGradKernel(const Context& dev_ctx, std::tie(x_bst_dims_vec, y_bst_dims_vec) = funcs::MatrixGetBroadcastDims(x, y); - ScalarArray y_bst_dims_array(y_bst_dims_vec); + IntArray y_bst_dims_array(y_bst_dims_vec); DenseTensor dy_bst = phi::Empty(dev_ctx, y_bst_dims_array); if (dy) { // calculate x's conjugate for complex @@ -71,7 +71,7 @@ void TriangularSolveGradKernel(const Context& dev_ctx, } } - ScalarArray x_bst_dims_array(x_bst_dims_vec); + IntArray x_bst_dims_array(x_bst_dims_vec); DenseTensor dx_bst = phi::Empty(dev_ctx, x_bst_dims_array); if (dx) { // calculate x's conjugate for complex diff --git a/paddle/phi/kernels/impl/unsqueeze_kernel_impl.h b/paddle/phi/kernels/impl/unsqueeze_kernel_impl.h index 884fa26df451c680fe8352f0c0b21b2ce8a33b6c..58efff16a5a5ac44e5ab6b91909d385b03795c8e 100644 --- a/paddle/phi/kernels/impl/unsqueeze_kernel_impl.h +++ b/paddle/phi/kernels/impl/unsqueeze_kernel_impl.h @@ -21,7 +21,7 @@ namespace phi { template void UnsqueezeKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& axes, + const IntArray& axes, DenseTensor* xshape, DenseTensor* out) { auto x_dims = x.dims(); diff --git a/paddle/phi/kernels/pad3d_grad_kernel.h b/paddle/phi/kernels/pad3d_grad_kernel.h index 38f1e5335e8c240058fb3b52a8ae59a0c438b61c..bbad50f4d83bd46197d677b11e5b7466794421ad 100644 --- a/paddle/phi/kernels/pad3d_grad_kernel.h +++ b/paddle/phi/kernels/pad3d_grad_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -23,7 +23,7 @@ template void Pad3dGradKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, - const ScalarArray& paddings, + const IntArray& paddings, const std::string& mode, float pad_value, const std::string& data_format, diff --git a/paddle/phi/kernels/pad3d_kernel.h b/paddle/phi/kernels/pad3d_kernel.h index d8876c3e7bc74f6f03413f00279bfaa355907c6b..1589ff854ec23d2a9dbbfa42200b73e33e58cf9f 100644 --- a/paddle/phi/kernels/pad3d_kernel.h +++ b/paddle/phi/kernels/pad3d_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -22,7 +22,7 @@ namespace phi { template void Pad3dKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& paddings, + const IntArray& paddings, const std::string& mode, float pad_value, const std::string& data_format, diff --git a/paddle/phi/kernels/randint_kernel.h b/paddle/phi/kernels/randint_kernel.h index bfefc628614fbc03c484a43f31a7194da15a2bf9..85d440e305635d6126833526b450946ed4c169c8 100644 --- a/paddle/phi/kernels/randint_kernel.h +++ b/paddle/phi/kernels/randint_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -23,7 +23,7 @@ template void RandintKernel(const Context& dev_ctx, int low, int high, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, DenseTensor* out); @@ -31,7 +31,7 @@ template void RandintRawKernel(const Context& dev_ctx, int low, int high, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, int seed, DenseTensor* out); diff --git a/paddle/phi/kernels/reshape_kernel.cc b/paddle/phi/kernels/reshape_kernel.cc index 12a75a838058a4b068b7a622c13916e09b013c53..efcad999b447d4d9ec5feff3b8eec9a4e5c2266f 100644 --- a/paddle/phi/kernels/reshape_kernel.cc +++ b/paddle/phi/kernels/reshape_kernel.cc @@ -24,7 +24,7 @@ namespace phi { template void ReshapeKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& shape, + const IntArray& shape, DenseTensor* out) { MetaTensor meta_out(out); InferMetaFromVecValue(x, shape.GetData(), &meta_out); @@ -44,7 +44,7 @@ void ReshapeKernel(const Context& dev_ctx, template void ReshapeWithXShape(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& shape, + const IntArray& shape, DenseTensor* out, DenseTensor* xshape) { ReshapeKernel(dev_ctx, x, shape, out); diff --git a/paddle/phi/kernels/reshape_kernel.h b/paddle/phi/kernels/reshape_kernel.h index 11b19766a918bbc884f96e68a1a44db09609ce14..88b1bd958714089291a63ea1f8714d5549400277 100644 --- a/paddle/phi/kernels/reshape_kernel.h +++ b/paddle/phi/kernels/reshape_kernel.h @@ -14,7 +14,7 @@ limitations under the License. */ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/infermeta/unary.h" #include "paddle/phi/kernels/empty_kernel.h" @@ -24,13 +24,13 @@ namespace phi { template void ReshapeKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& shape, + const IntArray& shape, DenseTensor* out); template void ReshapeWithXShape(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& shape, + const IntArray& shape, DenseTensor* out, DenseTensor* xshape); @@ -41,7 +41,7 @@ DenseTensor Reshape(const Context& dev_ctx, DenseTensor dense_out; MetaTensor meta_out(&dense_out); InferMetaFromVecValue(x, shape, &meta_out); - ReshapeKernel(dev_ctx, x, ScalarArray(shape), &dense_out); + ReshapeKernel(dev_ctx, x, IntArray(shape), &dense_out); return dense_out; } diff --git a/paddle/phi/kernels/roll_grad_kernel.h b/paddle/phi/kernels/roll_grad_kernel.h index 331f3626e56574615a2d6b1680335638b060846d..82e9c0249f7af8907d5c0f4ad2ddec3c46b006ab 100644 --- a/paddle/phi/kernels/roll_grad_kernel.h +++ b/paddle/phi/kernels/roll_grad_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -23,7 +23,7 @@ template void RollGradKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, - const ScalarArray& shifts, + const IntArray& shifts, const std::vector& axis, DenseTensor* x_grad); diff --git a/paddle/phi/kernels/roll_kernel.h b/paddle/phi/kernels/roll_kernel.h index 56f32174a4c0005968acf147b2daf25914ff01b1..4e0c41b8b8de841eef6030d3e8b9c55b4630e8e0 100644 --- a/paddle/phi/kernels/roll_kernel.h +++ b/paddle/phi/kernels/roll_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -22,7 +22,7 @@ namespace phi { template void RollKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& shifts, + const IntArray& shifts, const std::vector& axis, DenseTensor* out); diff --git a/paddle/phi/kernels/selected_rows/full_kernel.cc b/paddle/phi/kernels/selected_rows/full_kernel.cc index 39fd009cd6586bd7413e9d215607603f5d0d2b0a..03cd7fed411f30052fcb2a47cc10684f394efb64 100644 --- a/paddle/phi/kernels/selected_rows/full_kernel.cc +++ b/paddle/phi/kernels/selected_rows/full_kernel.cc @@ -29,7 +29,7 @@ namespace sr { template void FullKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, const Scalar& val, DataType dtype, SelectedRows* out) { diff --git a/paddle/phi/kernels/selected_rows/full_kernel.h b/paddle/phi/kernels/selected_rows/full_kernel.h index d84ddcc0d3f63bdc95db97a933f53076baa8a02c..d4b1859fdfcfb6ec6bdfccfcc9dfc28741b12bc5 100644 --- a/paddle/phi/kernels/selected_rows/full_kernel.h +++ b/paddle/phi/kernels/selected_rows/full_kernel.h @@ -14,8 +14,8 @@ #pragma once +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/selected_rows.h" namespace phi { @@ -23,7 +23,7 @@ namespace sr { template void FullKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, const Scalar& val, DataType dtype, SelectedRows* out); diff --git a/paddle/phi/kernels/selected_rows/uniform_random_kernel.cc b/paddle/phi/kernels/selected_rows/uniform_random_kernel.cc index b3dd1d1b7d2a025a80123f480a9deeb0f7ca5932..ce2bbc533f703e73ff03f5e4c57f1a66103ab8e9 100644 --- a/paddle/phi/kernels/selected_rows/uniform_random_kernel.cc +++ b/paddle/phi/kernels/selected_rows/uniform_random_kernel.cc @@ -24,7 +24,7 @@ namespace sr { template void UniformRandomRawKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, float min, float max, @@ -47,7 +47,7 @@ void UniformRandomRawKernel(const Context& dev_ctx, template void UniformRandomKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, float min, float max, diff --git a/paddle/phi/kernels/selected_rows/uniform_random_kernel.h b/paddle/phi/kernels/selected_rows/uniform_random_kernel.h index aee7a4c7aaf62d9250246f326ca009268af92d5e..d0a9084b40b3755760eebbebfadd99ee7c33d243 100644 --- a/paddle/phi/kernels/selected_rows/uniform_random_kernel.h +++ b/paddle/phi/kernels/selected_rows/uniform_random_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/selected_rows.h" namespace phi { @@ -22,7 +22,7 @@ namespace sr { template void UniformRandomRawKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, float min, float max, @@ -34,7 +34,7 @@ void UniformRandomRawKernel(const Context& dev_ctx, template void UniformRandomKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, float min, float max, diff --git a/paddle/phi/kernels/set_value_grad_kernel.h b/paddle/phi/kernels/set_value_grad_kernel.h index 6a028b0c8dc50fb068de1ded367990c409bd45cb..3ee95d76281935ff34399d9e9117513b3bf89b87 100644 --- a/paddle/phi/kernels/set_value_grad_kernel.h +++ b/paddle/phi/kernels/set_value_grad_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -22,9 +22,9 @@ namespace phi { template void SetValueGradKernel(const Context& dev_ctx, const DenseTensor& out_grad, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& steps, + const IntArray& starts, + const IntArray& ends, + const IntArray& steps, const std::vector& axes, const std::vector& decrease_axes, const std::vector& none_axes, diff --git a/paddle/phi/kernels/set_value_kernel.h b/paddle/phi/kernels/set_value_kernel.h index 271691b1a3596f773cb67d605c76d6b8f142c1b6..69fd88f02e8521be2dc7e44d71673bce01e1ca5c 100644 --- a/paddle/phi/kernels/set_value_kernel.h +++ b/paddle/phi/kernels/set_value_kernel.h @@ -14,8 +14,8 @@ #pragma once +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/infermeta/unary.h" @@ -25,9 +25,9 @@ template void SetTensorValueKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& value, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& steps, + const IntArray& starts, + const IntArray& ends, + const IntArray& steps, const std::vector& axes, const std::vector& decrease_axes, const std::vector& none_axes, @@ -36,9 +36,9 @@ void SetTensorValueKernel(const Context& dev_ctx, template void SetValueKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& steps, + const IntArray& starts, + const IntArray& ends, + const IntArray& steps, const std::vector& axes, const std::vector& decrease_axes, const std::vector& none_axes, diff --git a/paddle/phi/kernels/slice_grad_kernel.h b/paddle/phi/kernels/slice_grad_kernel.h index a7ee9ffde4eb080627d688998cf751d5bcb203a7..a74b432c2b1b9edae25f830b55319ddbf9d9df31 100644 --- a/paddle/phi/kernels/slice_grad_kernel.h +++ b/paddle/phi/kernels/slice_grad_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -24,8 +24,8 @@ void SliceGradRawKernel(const Context& ctx, const DenseTensor& input, const DenseTensor& out_grad, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, + const IntArray& starts, + const IntArray& ends, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* input_grad); diff --git a/paddle/phi/kernels/slice_kernel.h b/paddle/phi/kernels/slice_kernel.h index ff27824b9e676ca5b28f2ebb9e655c8c48d0deb0..c2a96312cdd5e20fd3e7333a0483a0339c9783be 100644 --- a/paddle/phi/kernels/slice_kernel.h +++ b/paddle/phi/kernels/slice_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -23,8 +23,8 @@ template void SliceRawKernel(const Context& ctx, const DenseTensor& input, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, + const IntArray& starts, + const IntArray& ends, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* out); diff --git a/paddle/phi/kernels/split_kernel.h b/paddle/phi/kernels/split_kernel.h index e42b25e60c42291b3949c144c4aba6f62ec98a44..6baac241426c74cbc9a5f4c855555b39a8c33ada 100644 --- a/paddle/phi/kernels/split_kernel.h +++ b/paddle/phi/kernels/split_kernel.h @@ -16,8 +16,8 @@ #include "paddle/phi/core/dense_tensor.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/infermeta/unary.h" #include "paddle/phi/kernels/empty_kernel.h" @@ -26,14 +26,14 @@ namespace phi { template void SplitKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& num_or_sections, + const IntArray& num_or_sections, const Scalar& axis, std::vector out); template std::vector Split(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& num_or_sections, + const IntArray& num_or_sections, const Scalar& axis) { size_t out_number; if (num_or_sections.GetData().size() == 1) { diff --git a/paddle/phi/kernels/strided_slice_grad_kernel.h b/paddle/phi/kernels/strided_slice_grad_kernel.h index f753402e498338a5262d9e1bf3065fe0477fbb49..07fba9d27bfe90fe4c94bf2c3f03b0e080fc8da0 100644 --- a/paddle/phi/kernels/strided_slice_grad_kernel.h +++ b/paddle/phi/kernels/strided_slice_grad_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -24,9 +24,9 @@ void StridedSliceGradKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* x_grad); @@ -37,9 +37,9 @@ void StridedSliceArrayGradKernel( const std::vector& x, const std::vector& out_grad, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, std::vector x_grad); diff --git a/paddle/phi/kernels/strided_slice_kernel.h b/paddle/phi/kernels/strided_slice_kernel.h index f23d1c04d5da37376a3fa949fb9d3f2c5a29de5d..fd90d81b8556c210c05474219a0635b27d1a4223 100644 --- a/paddle/phi/kernels/strided_slice_kernel.h +++ b/paddle/phi/kernels/strided_slice_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -23,9 +23,9 @@ template void StridedSliceKernel(const Context& dev_ctx, const DenseTensor& x, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* out); @@ -34,9 +34,9 @@ template void StridedSliceArrayKernel(const Context& dev_ctx, const std::vector& x, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, - const ScalarArray& strides, + const IntArray& starts, + const IntArray& ends, + const IntArray& strides, const std::vector& infer_flags, const std::vector& decrease_axis, std::vector out); diff --git a/paddle/phi/kernels/strings/strings_empty_kernel.cc b/paddle/phi/kernels/strings/strings_empty_kernel.cc index b8df19fdba8cfb312634e099efc7f3c8fe435116..433d3ad0a95f66146cb91339ef344254a207867f 100644 --- a/paddle/phi/kernels/strings/strings_empty_kernel.cc +++ b/paddle/phi/kernels/strings/strings_empty_kernel.cc @@ -22,7 +22,7 @@ namespace strings { template void EmptyKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, StringTensor* out) { out->Resize(phi::make_ddim(shape.GetData())); dev_ctx.template Alloc(out); diff --git a/paddle/phi/kernels/strings/strings_empty_kernel.h b/paddle/phi/kernels/strings/strings_empty_kernel.h index 7f416375f6b433c36ca93b88d78aeb802cab731e..1add1963614d83c036fdb20be9b282471e570bf0 100644 --- a/paddle/phi/kernels/strings/strings_empty_kernel.h +++ b/paddle/phi/kernels/strings/strings_empty_kernel.h @@ -16,7 +16,7 @@ #include "paddle/phi/api/lib/utils/allocator.h" #include "paddle/phi/api/lib/utils/storage.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/string_tensor.h" #include "paddle/phi/infermeta/strings/nullary.h" #include "paddle/phi/infermeta/strings/unary.h" @@ -26,7 +26,7 @@ namespace strings { template void EmptyKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, StringTensor* out); template @@ -48,7 +48,7 @@ StringTensor Empty(const Context& dev_ctx) { } template -StringTensor Empty(const Context& dev_ctx, const ScalarArray& shape) { +StringTensor Empty(const Context& dev_ctx, const IntArray& shape) { StringTensor string_out; MetaTensor meta_out(&string_out); phi::strings::CreateInferMeta(shape, &meta_out); diff --git a/paddle/phi/kernels/tile_grad_kernel.h b/paddle/phi/kernels/tile_grad_kernel.h index 830276c28e05395c36854426e560fbe6f2642589..d40a0f4dfce7b24b63b18395f3c4fea83279e44e 100644 --- a/paddle/phi/kernels/tile_grad_kernel.h +++ b/paddle/phi/kernels/tile_grad_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" #define MAX_RANK_SUPPORTED 6 @@ -25,7 +25,7 @@ template void TileGradKernel(const Context& dev_ctx, const DenseTensor& x, const DenseTensor& out_grad, - const ScalarArray& repeat_times, + const IntArray& repeat_times, DenseTensor* x_grad); } // namespace phi diff --git a/paddle/phi/kernels/tile_kernel.h b/paddle/phi/kernels/tile_kernel.h index 924d0149fe34598753f0d02cfa3b087e2e7493f2..32e3685e8569e46b509e1df4e554f2bdbde933a7 100644 --- a/paddle/phi/kernels/tile_kernel.h +++ b/paddle/phi/kernels/tile_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" #define MAX_RANK_SUPPORTED 6 @@ -24,7 +24,7 @@ namespace phi { template void TileKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& repeat_times, + const IntArray& repeat_times, DenseTensor* out); } // namespace phi diff --git a/paddle/phi/kernels/truncated_gaussian_random_kernel.h b/paddle/phi/kernels/truncated_gaussian_random_kernel.h index f8547ced41934a9810dc6874c090ab5aefd43497..2781b79520a5d05bf957a5139c720f6639da334f 100644 --- a/paddle/phi/kernels/truncated_gaussian_random_kernel.h +++ b/paddle/phi/kernels/truncated_gaussian_random_kernel.h @@ -17,7 +17,7 @@ #include #include -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/device_context.h" #include "paddle/phi/infermeta/nullary.h" diff --git a/paddle/phi/kernels/uniform_random_kernel.h b/paddle/phi/kernels/uniform_random_kernel.h index 36ce4c3f9eef58a55d41e0230c3ebfc3e768e6b3..03eca83db03acda88f40a6d6797ba45fa2465890 100644 --- a/paddle/phi/kernels/uniform_random_kernel.h +++ b/paddle/phi/kernels/uniform_random_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/device_context.h" @@ -22,7 +22,7 @@ namespace phi { template void UniformRandomRawKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, float min, float max, @@ -34,7 +34,7 @@ void UniformRandomRawKernel(const Context& dev_ctx, template void UniformRandomKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, DataType dtype, float min, float max, diff --git a/paddle/phi/kernels/unsqueeze_kernel.h b/paddle/phi/kernels/unsqueeze_kernel.h index 8f818a1b4904223e093c18107168afde2fd599a5..d18bde1c2efab996ae40df0282bf9866281ab98b 100644 --- a/paddle/phi/kernels/unsqueeze_kernel.h +++ b/paddle/phi/kernels/unsqueeze_kernel.h @@ -15,7 +15,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -23,7 +23,7 @@ namespace phi { template void UnsqueezeKernel(const Context& dev_ctx, const DenseTensor& x, - const ScalarArray& axes, + const IntArray& axes, DenseTensor* xshape, DenseTensor* out); } // namespace phi diff --git a/paddle/phi/kernels/xpu/full_kernel.cc b/paddle/phi/kernels/xpu/full_kernel.cc index d43126d56e88c868d4e273aaf13bd71bc570d37c..6668ae39cbdbe8d0f9385306143b2ba94ea59fb0 100644 --- a/paddle/phi/kernels/xpu/full_kernel.cc +++ b/paddle/phi/kernels/xpu/full_kernel.cc @@ -55,7 +55,7 @@ void FullValueXPU(const Context& dev_ctx, DenseTensor* tensor, VType val) { template void FullKernel(const Context& dev_ctx, - const ScalarArray& shape, + const IntArray& shape, const Scalar& val, DataType dtype, DenseTensor* out) { diff --git a/paddle/phi/tests/api/scale_api.h b/paddle/phi/tests/api/scale_api.h index 8e92c9fc3aa5dbb8975d09b8fc93113243155a77..190fef3d94657fc5eb0c4ab019654772a56b563f 100644 --- a/paddle/phi/tests/api/scale_api.h +++ b/paddle/phi/tests/api/scale_api.h @@ -20,8 +20,8 @@ #include "paddle/phi/api/lib/kernel_dispatch.h" #include "paddle/phi/api/lib/utils/allocator.h" #include "paddle/phi/api/lib/utils/storage.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/core/meta_tensor.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/phi/tests/core/test_custom_kernel.cc b/paddle/phi/tests/core/test_custom_kernel.cc index 6fe34a6891a35efb0af7e1785a2341988142be79..07530f70b7ab5017f6167f8c04707cb6ac06d01d 100644 --- a/paddle/phi/tests/core/test_custom_kernel.cc +++ b/paddle/phi/tests/core/test_custom_kernel.cc @@ -24,8 +24,8 @@ limitations under the License. */ #include "paddle/fluid/platform/device_context.h" #include "paddle/phi/api/lib/utils/allocator.h" #include "paddle/phi/api/lib/utils/storage.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" #include "paddle/phi/core/kernel_context.h" #include "paddle/phi/core/kernel_factory.h" #include "paddle/phi/core/kernel_registry.h" @@ -52,7 +52,7 @@ void FakeDot(const Context& dev_ctx, phi::dtype::float16 fake_attr_f16, phi::DataType fake_attr_dtype, const phi::Scalar& fake_attr_scalar, - const phi::ScalarArray& fake_attr_scalar_array, + const phi::IntArray& fake_attr_int_array, const std::vector& fake_attr_int64_vec, const std::vector& fake_attr_int_vec, phi::DenseTensor* out, @@ -253,7 +253,7 @@ TEST(CustomKernel, custom_kernel_dot) { paddle::framework::LoDTensor tmp_tensor; tmp_tensor.mutable_data({1}, phi::TransToPhiPlace(backend)); phi::Scalar fake_attr_scalar{tmp_tensor}; - phi::ScalarArray fake_attr_scalar_array; + phi::IntArray fake_attr_int_array; std::vector fake_attr_int64_vec; std::vector fake_attr_int_vec; @@ -265,7 +265,7 @@ TEST(CustomKernel, custom_kernel_dot) { kernel_context.EmplaceBackAttr(fake_attr_f16); kernel_context.EmplaceBackAttr(fake_attr_dtype); kernel_context.EmplaceBackAttr(fake_attr_scalar); - kernel_context.EmplaceBackAttr(fake_attr_scalar_array); + kernel_context.EmplaceBackAttr(fake_attr_int_array); kernel_context.EmplaceBackAttr(fake_attr_int64_vec); kernel_context.EmplaceBackAttr(fake_attr_int_vec); diff --git a/paddle/phi/tests/core/test_meta_fn_utils.cc b/paddle/phi/tests/core/test_meta_fn_utils.cc index 399112d09c2ad55364b5035e7b759b53d0abaea8..c90e2f3dbcdedca876648883be902df7244821bc 100644 --- a/paddle/phi/tests/core/test_meta_fn_utils.cc +++ b/paddle/phi/tests/core/test_meta_fn_utils.cc @@ -100,7 +100,7 @@ TEST(MetaFnFactory, SplitInferMetaFn) { phi::InferMetaContext ctx; ctx.EmplaceBackInput(shared_meat_x); - ScalarArray num_or_sections{2, 2}; + IntArray num_or_sections{2, 2}; Scalar axis{0}; ctx.EmplaceBackAttr(num_or_sections); ctx.EmplaceBackAttr(axis); diff --git a/paddle/pten/kernels/slice_kernel.h b/paddle/pten/kernels/slice_kernel.h index ff27824b9e676ca5b28f2ebb9e655c8c48d0deb0..c2a96312cdd5e20fd3e7333a0483a0339c9783be 100644 --- a/paddle/pten/kernels/slice_kernel.h +++ b/paddle/pten/kernels/slice_kernel.h @@ -14,7 +14,7 @@ #pragma once -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/phi/core/dense_tensor.h" namespace phi { @@ -23,8 +23,8 @@ template void SliceRawKernel(const Context& ctx, const DenseTensor& input, const std::vector& axes, - const ScalarArray& starts, - const ScalarArray& ends, + const IntArray& starts, + const IntArray& ends, const std::vector& infer_flags, const std::vector& decrease_axis, DenseTensor* out); diff --git a/python/paddle/utils/code_gen/api.yaml b/python/paddle/utils/code_gen/api.yaml index bd391d0e0107cbdbcf0227f8c18bcaab3ae235c8..89e6f9faafacdf1c3096a67b839af0527777e9d3 100644 --- a/python/paddle/utils/code_gen/api.yaml +++ b/python/paddle/utils/code_gen/api.yaml @@ -60,7 +60,7 @@ # # expand # - api : expand -# args : (Tensor x, ScalarArray shape) +# args : (Tensor x, IntArray shape) # output : Tensor # infer_meta : # func : ExpandInferMeta @@ -79,7 +79,7 @@ # gaussian_random # - api : gaussian_random -# args : (ScalarArray shape, float mean, float std, int seed, DataType dtype=DataType::FLOAT32) +# args : (IntArray shape, float mean, float std, int seed, DataType dtype=DataType::FLOAT32) # output : Tensor # infer_meta : # func : CreateInferMeta @@ -155,7 +155,7 @@ # # randint # - api : randint -# args : (int low, int high, ScalarArray shape, DataType dtype) +# args : (int low, int high, IntArray shape, DataType dtype) # output : Tensor # infer_meta : # func : RandintInferMeta @@ -645,7 +645,7 @@ backward : elu_grad - api : empty - args : (ScalarArray shape, DataType dtype=DataType::FLOAT32, Place place=CPUPlace()) + args : (IntArray shape, DataType dtype=DataType::FLOAT32, Place place=CPUPlace()) output: Tensor infer_meta : func : CreateInferMeta @@ -714,7 +714,7 @@ func : flip - api : full - args : (ScalarArray shape, Scalar value, DataType dtype=DataType::FLOAT32, Place place=CPUPlace()) + args : (IntArray shape, Scalar value, DataType dtype=DataType::FLOAT32, Place place=CPUPlace()) output: Tensor infer_meta : func : CreateInferMeta @@ -1133,7 +1133,7 @@ backward : relu_grad - api : reshape - args : (Tensor x, ScalarArray shape) + args : (Tensor x, IntArray shape) output : Tensor(out), Tensor(xshape) infer_meta : func : ReshapeWithXShapeInferMeta @@ -1294,7 +1294,7 @@ backward : softmax_grad - api : split - args : (Tensor x, ScalarArray num_or_sections, Scalar(int) axis) + args : (Tensor x, IntArray num_or_sections, Scalar(int) axis) output : Tensor[] invoke : split_impl(x, num_or_sections, axis) @@ -1390,7 +1390,7 @@ # tile - api : tile - args : (Tensor x, ScalarArray repeat_times) + args : (Tensor x, IntArray repeat_times) output : Tensor infer_meta : func : TileInferMeta diff --git a/python/paddle/utils/code_gen/api_base.py b/python/paddle/utils/code_gen/api_base.py index 1c58334794da1e33034998829c7d74c0a32b3419..e281484f69744d73f4e2c6f67dac03befee23d75 100644 --- a/python/paddle/utils/code_gen/api_base.py +++ b/python/paddle/utils/code_gen/api_base.py @@ -88,7 +88,7 @@ class BaseAPI(object): 'Tensor[]': 'const std::vector&' } attr_types_map = { - 'ScalarArray': 'const ScalarArray&', + 'IntArray': 'const IntArray&', 'Scalar': 'const Scalar&', 'Scalar(int)': 'const Scalar&', 'Scalar(int64_t)': 'const Scalar&', @@ -600,9 +600,9 @@ PADDLE_API {self.gene_return_type_code()} {self.get_api_func_name() + '_'}({self kernel_args_type_list.append(kernel_in_type) elif param in attr_names: # set attr for kernel_context - if 'ScalarArray' in self.attrs['attr_info'][param][0]: - kernel_args_type_list.append('const phi::ScalarArray&') - param = 'phi::ScalarArray(' + param + ')' + if 'IntArray' in self.attrs['attr_info'][param][0]: + kernel_args_type_list.append('const phi::IntArray&') + param = 'phi::IntArray(' + param + ')' elif 'Scalar' in self.attrs['attr_info'][param][0]: kernel_args_type_list.append('const phi::Scalar&') param = 'phi::Scalar(' + param + ')' @@ -665,9 +665,9 @@ PADDLE_API {self.gene_return_type_code()} {self.get_api_func_name() + '_'}({self kernel_args_type_list.append(kernel_in_type) elif param in attr_names: # set attr for kernel_context - if 'ScalarArray' in self.attrs['attr_info'][param][0]: - kernel_args_type_list.append('const phi::ScalarArray&') - param = 'phi::ScalarArray(' + param + ')' + if 'IntArray' in self.attrs['attr_info'][param][0]: + kernel_args_type_list.append('const phi::IntArray&') + param = 'phi::IntArray(' + param + ')' elif 'Scalar' in self.attrs['attr_info'][param][0]: kernel_args_type_list.append('const phi::Scalar&') param = 'phi::Scalar(' + param + ')' diff --git a/python/paddle/utils/code_gen/api_gen.py b/python/paddle/utils/code_gen/api_gen.py index c8644a8812bd256f736343187086535e1ea79e9a..f95edf6c591abc050db4901698d4eab859aebbd0 100644 --- a/python/paddle/utils/code_gen/api_gen.py +++ b/python/paddle/utils/code_gen/api_gen.py @@ -138,7 +138,7 @@ def header_include(): #include "paddle/phi/api/include/tensor.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/utils/optional.h" """ diff --git a/python/paddle/utils/code_gen/backward.yaml b/python/paddle/utils/code_gen/backward.yaml index 9a5ee7a42ef2cafbbe22c78ee6b4092e101144c4..2d893dc855fc0860863b2ea521300434b87475a8 100644 --- a/python/paddle/utils/code_gen/backward.yaml +++ b/python/paddle/utils/code_gen/backward.yaml @@ -109,8 +109,8 @@ # func : expand_as_grad # - backward_api : expand_grad -# forward : expand (Tensor x, ScalarArray shape) -> Tensor(out) -# args : (Tensor x, Tensor out_grad, ScalarArray shape) +# forward : expand (Tensor x, IntArray shape) -> Tensor(out) +# args : (Tensor x, Tensor out_grad, IntArray shape) # output : Tensor(x_grad) # infer_meta : # func : UnchangedGradInferMeta @@ -684,7 +684,7 @@ backward: relu_double_grad - backward_api : reshape_grad - forward : reshape_with_xshape (Tensor x, ScalarArray shape) -> Tensor(out), Tensor(xshape) + forward : reshape_with_xshape (Tensor x, IntArray shape) -> Tensor(out), Tensor(xshape) args : (Tensor xshape, Tensor out_grad) output : Tensor(x_grad) infer_meta : @@ -814,7 +814,7 @@ func : softmax_grad - backward_api : split_grad - forward : split (Tensor x, ScalarArray num_or_sections, Scalar axis) -> Tensor[](out) + forward : split (Tensor x, IntArray num_or_sections, Scalar axis) -> Tensor[](out) args : (Tensor[] out_grad, Scalar axis) output : Tensor(x_grad) invoke : concat( out_grad, axis) @@ -901,8 +901,8 @@ func : thresholded_relu_grad - backward_api : tile_grad - forward : tile (Tensor x, ScalarArray repeat_times) -> Tensor(out) - args : (Tensor x, Tensor out_grad, ScalarArray repeat_times) + forward : tile (Tensor x, IntArray repeat_times) -> Tensor(out) + args : (Tensor x, Tensor out_grad, IntArray repeat_times) output : Tensor(x_grad) infer_meta : func : UnchangedInferMeta diff --git a/python/paddle/utils/code_gen/backward_api_gen.py b/python/paddle/utils/code_gen/backward_api_gen.py index bf3c7752362840d30a6ac97db6c7addf31c44923..e26f65387878c75468f8b3bdefabeb6ec83bd9fc 100644 --- a/python/paddle/utils/code_gen/backward_api_gen.py +++ b/python/paddle/utils/code_gen/backward_api_gen.py @@ -156,7 +156,7 @@ def header_include(): #include "paddle/phi/api/include/tensor.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/utils/optional.h" """ diff --git a/python/paddle/utils/code_gen/intermediate_api_gen.py b/python/paddle/utils/code_gen/intermediate_api_gen.py index 9f6b1e16a20316ddad637a2e162ddbcc68455f15..6e1df7b4ec3369d069042a8d3eb9ecd871989858 100644 --- a/python/paddle/utils/code_gen/intermediate_api_gen.py +++ b/python/paddle/utils/code_gen/intermediate_api_gen.py @@ -27,7 +27,7 @@ def header_include(): #include "paddle/phi/api/include/tensor.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/utils/optional.h" """ diff --git a/python/paddle/utils/code_gen/sparse_api_gen.py b/python/paddle/utils/code_gen/sparse_api_gen.py index ba63217068fd87281f2e751c3b997462ca42e7c7..c0316fc1642946d641326d5bde4eb77ac50f8129 100644 --- a/python/paddle/utils/code_gen/sparse_api_gen.py +++ b/python/paddle/utils/code_gen/sparse_api_gen.py @@ -113,8 +113,8 @@ PADDLE_API {self.outputs['return_type']} {self.get_api_func_name()}({self.args_s continue if param in attr_names: # set attr for kernel_context - if 'ScalarArray' in self.attrs['attr_info'][param][0]: - param = 'phi::ScalarArray(' + param + ')' + if 'IntArray' in self.attrs['attr_info'][param][0]: + param = 'phi::IntArray(' + param + ')' elif 'Scalar' in self.attrs['attr_info'][param][0]: param = 'phi::Scalar(' + param + ')' elif isinstance(param, bool): @@ -167,7 +167,7 @@ def header_include(): #include "paddle/phi/api/include/tensor.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/utils/optional.h" """ diff --git a/python/paddle/utils/code_gen/sparse_bw_api_gen.py b/python/paddle/utils/code_gen/sparse_bw_api_gen.py index 9f74cf9ad58cce35f703ebfffd883b41e09c38b8..4f209a7592161b37cb48d04130966c0ccac1c26b 100644 --- a/python/paddle/utils/code_gen/sparse_bw_api_gen.py +++ b/python/paddle/utils/code_gen/sparse_bw_api_gen.py @@ -97,7 +97,7 @@ def header_include(): return """ #include "paddle/phi/api/include/tensor.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/utils/optional.h" """ diff --git a/python/paddle/utils/code_gen/strings_api.yaml b/python/paddle/utils/code_gen/strings_api.yaml index 14bcafe2281aedb40a102dd60f6a76ec5aea46df..34dac9221a4a0d6b106d79e68b38211c97a43597 100644 --- a/python/paddle/utils/code_gen/strings_api.yaml +++ b/python/paddle/utils/code_gen/strings_api.yaml @@ -1,5 +1,5 @@ - api : empty - args : (ScalarArray shape, Place place=CPUPlace()) + args : (IntArray shape, Place place=CPUPlace()) output : Tensor(out@StringTensor) infer_meta : func : strings::CreateInferMeta diff --git a/python/paddle/utils/code_gen/strings_api_gen.py b/python/paddle/utils/code_gen/strings_api_gen.py index 42344ecb7d193f8bd8026e051f0ab444098ba4d4..d7117e9d540606a9dc0e95d104ab9c999a3eb937 100644 --- a/python/paddle/utils/code_gen/strings_api_gen.py +++ b/python/paddle/utils/code_gen/strings_api_gen.py @@ -144,9 +144,9 @@ PADDLE_API {self.outputs['return_type']} {self.get_api_func_name()}({self.args_s kernel_args_type_list.append(kernel_in_type) elif param in attr_names: # set attr for kernel_context - if 'ScalarArray' in self.attrs['attr_info'][param][0]: - kernel_args_type_list.append('const phi::ScalarArray&') - param = 'phi::ScalarArray(' + param + ')' + if 'IntArray' in self.attrs['attr_info'][param][0]: + kernel_args_type_list.append('const phi::IntArray&') + param = 'phi::IntArray(' + param + ')' elif 'Scalar' in self.attrs['attr_info'][param][0]: kernel_args_type_list.append('const phi::Scalar&') param = 'phi::Scalar(' + param + ')' @@ -277,7 +277,7 @@ def header_include(): #include "paddle/phi/api/include/tensor.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" #include "paddle/utils/optional.h" """ diff --git a/python/paddle/utils/code_gen/wrapped_infermeta_gen.py b/python/paddle/utils/code_gen/wrapped_infermeta_gen.py index 13c35813aab7d47840bee1bf0686e0c06b96efdc..39b950e15dc9366aad2121d48e3ed163a1cf96a9 100644 --- a/python/paddle/utils/code_gen/wrapped_infermeta_gen.py +++ b/python/paddle/utils/code_gen/wrapped_infermeta_gen.py @@ -92,7 +92,7 @@ def header_include(): return """ #include "paddle/phi/core/meta_tensor.h" #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/scalar_array.h" +#include "paddle/phi/common/int_array.h" """