未验证 提交 7e383885 编写于 作者: A Aurelius84 提交者: GitHub

[IR]Polish Construct function arugment (#55004)

上级 eef38db1
......@@ -28,7 +28,7 @@ struct KernelAttributeStorage : public ir::AttributeStorage {
explicit KernelAttributeStorage(const ParamKey &key) { kernel_key_ = key; }
static KernelAttributeStorage *Construct(ParamKey key) {
static KernelAttributeStorage *Construct(const ParamKey &key) {
return new KernelAttributeStorage(key);
}
......
......@@ -37,15 +37,15 @@ struct AllocatedDenseTensorTypeStorage : public ir::TypeStorage {
///
using ParamKey = std::tuple<phi::Place, dialect::DenseTensorType>;
AllocatedDenseTensorTypeStorage(phi::Place place,
dialect::DenseTensorType type)
AllocatedDenseTensorTypeStorage(const phi::Place& place,
const dialect::DenseTensorType& type)
: place_(place), dense_tensor_type_(type) {}
///
/// \brief Each derived TypeStorage must define a Construct method, which
/// StorageManager uses to construct a derived TypeStorage.
///
static AllocatedDenseTensorTypeStorage *Construct(ParamKey key) {
static AllocatedDenseTensorTypeStorage* Construct(const ParamKey& key) {
return new AllocatedDenseTensorTypeStorage(std::get<0>(key),
std::get<1>(key));
}
......@@ -53,7 +53,7 @@ struct AllocatedDenseTensorTypeStorage : public ir::TypeStorage {
///
/// \brief Each derived TypeStorage must provide a HashValue method.
///
static std::size_t HashValue(const ParamKey &key) {
static std::size_t HashValue(const ParamKey& key) {
std::size_t hash_value = 0;
// hash place
hash_value = ir::hash_combine(hash_value, std::get<0>(key).HashValue());
......@@ -74,7 +74,7 @@ struct AllocatedDenseTensorTypeStorage : public ir::TypeStorage {
///
/// \brief Each derived TypeStorage needs to overload operator==.
///
bool operator==(const ParamKey &key) const {
bool operator==(const ParamKey& key) const {
return ParamKey(place_, dense_tensor_type_) == key;
}
......
......@@ -29,7 +29,7 @@ struct IntArrayAttributeStorage : public ir::AttributeStorage {
explicit IntArrayAttributeStorage(const ParamKey &key) { data_ = key; }
static IntArrayAttributeStorage *Construct(ParamKey key) {
static IntArrayAttributeStorage *Construct(const ParamKey &key) {
return new IntArrayAttributeStorage(key);
}
......@@ -59,7 +59,7 @@ struct DataTypeAttributeStorage : public ir::AttributeStorage {
explicit DataTypeAttributeStorage(const ParamKey &key) { data_ = key; }
static DataTypeAttributeStorage *Construct(ParamKey key) {
static DataTypeAttributeStorage *Construct(const ParamKey &key) {
return new DataTypeAttributeStorage(key);
}
......@@ -80,7 +80,7 @@ struct PlaceAttributeStorage : public ir::AttributeStorage {
explicit PlaceAttributeStorage(const ParamKey &key) { data_ = key; }
static PlaceAttributeStorage *Construct(ParamKey key) {
static PlaceAttributeStorage *Construct(const ParamKey &key) {
return new PlaceAttributeStorage(key);
}
......@@ -99,7 +99,7 @@ struct DataLayoutAttributeStorage : public ir::AttributeStorage {
explicit DataLayoutAttributeStorage(const ParamKey &key) { data_ = key; }
static DataLayoutAttributeStorage *Construct(ParamKey key) {
static DataLayoutAttributeStorage *Construct(const ParamKey &key) {
return new DataLayoutAttributeStorage(key);
}
......
......@@ -27,7 +27,7 @@ namespace std {
///
template <typename T>
struct hash<std::vector<T>> {
std::size_t operator()(const std::vector<T> &dim) const {
std::size_t operator()(const std::vector<T>& dim) const {
std::size_t seed = 0;
for (size_t i = 0; i < dim.size(); ++i) {
seed ^= std::hash<T>()(dim[i]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
......@@ -57,10 +57,10 @@ struct DenseTensorTypeStorage : public ir::TypeStorage {
using ParamKey =
std::tuple<ir::Type, phi::DDim, phi::DataLayout, phi::LoD, size_t>;
DenseTensorTypeStorage(ir::Type dtype,
phi::DDim dims,
phi::DataLayout layout,
phi::LoD lod,
DenseTensorTypeStorage(const ir::Type& dtype,
const phi::DDim& dims,
const phi::DataLayout& layout,
const phi::LoD& lod,
size_t offset)
: dtype_(dtype),
dims_(dims),
......@@ -72,7 +72,7 @@ struct DenseTensorTypeStorage : public ir::TypeStorage {
/// \brief Each derived TypeStorage must define a Construct method, which
/// StorageManager uses to construct a derived TypeStorage.
///
static DenseTensorTypeStorage *Construct(ParamKey key) {
static DenseTensorTypeStorage* Construct(const ParamKey& key) {
return new DenseTensorTypeStorage(std::get<0>(key),
std::get<1>(key),
std::get<2>(key),
......@@ -83,7 +83,7 @@ struct DenseTensorTypeStorage : public ir::TypeStorage {
///
/// \brief Each derived TypeStorage must provide a HashValue method.
///
static std::size_t HashValue(const ParamKey &key) {
static std::size_t HashValue(const ParamKey& key) {
std::size_t hash_value = 0;
// hash dtype
hash_value =
......@@ -109,7 +109,7 @@ struct DenseTensorTypeStorage : public ir::TypeStorage {
///
/// \brief Each derived TypeStorage needs to overload operator==.
///
bool operator==(const ParamKey &key) const {
bool operator==(const ParamKey& key) const {
return ParamKey(dtype_, dims_, layout_, lod_, offset_) == key;
}
......
......@@ -30,7 +30,7 @@ namespace ir {
\
explicit concrete_storage(const ParamKey &key) { data_ = key; } \
\
static concrete_storage *Construct(ParamKey key) { \
static concrete_storage *Construct(const ParamKey &key) { \
return new concrete_storage(key); \
} \
\
......@@ -60,7 +60,7 @@ struct StrAttributeStorage : public AttributeStorage {
~StrAttributeStorage() { free(data_); }
static StrAttributeStorage *Construct(ParamKey key) {
static StrAttributeStorage *Construct(const ParamKey &key) {
return new StrAttributeStorage(key);
}
......@@ -100,7 +100,7 @@ struct ArrayAttributeStorage : public AttributeStorage {
~ArrayAttributeStorage() { free(reinterpret_cast<void *>(data_)); }
static ArrayAttributeStorage *Construct(ParamKey key) {
static ArrayAttributeStorage *Construct(const ParamKey &key) {
return new ArrayAttributeStorage(key);
}
......
......@@ -36,7 +36,7 @@ struct VectorTypeStorage : public TypeStorage {
/// \brief Each derived TypeStorage must define a Construc method, which
/// StorageManager uses to construct a derived TypeStorage.
///
static VectorTypeStorage *Construct(ParamKey key) {
static VectorTypeStorage *Construct(const ParamKey &key) {
return new VectorTypeStorage(key);
}
......
......@@ -167,7 +167,7 @@ struct IntegerTypeStorage : public ir::TypeStorage {
return ParamKey(width_, signedness_) == key;
}
static IntegerTypeStorage *Construct(ParamKey key) {
static IntegerTypeStorage *Construct(const ParamKey &key) {
return new IntegerTypeStorage(key.first, key.second);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册