mlir-hlo/tools/mlir-tblgen-builder/Builder/Attribute.cpp

105 lines
3.8 KiB
C++
Raw Normal View History

2021-08-11 10:46:07 +08:00
#include "Attribute.h"
#include "AttributeImpl.h"
#include "llvm/Support/Casting.h"
#include "memory.h"
// #include "mlir/Dialect/StandardOps/Ops.h"
// #include "mlir/IR/Attributes.h"
// #include "mlir/IR/Operation.h"
// #include "mlir/IR/StandardTypes.h"
// #include "mlir/IR/Types.h"
// #include "mlir/IR/Value.h"
namespace builder {
2021-08-13 15:05:10 +08:00
inline bool PrimitiveType::operator==(const PrimitiveType& pt) {
return impl_ == pt.impl_;
}
PrimitiveType::PrimitiveType(std::shared_ptr<PrimitiveType::Impl> impl)
: impl_(impl) {}
PrimitiveType PrimitiveType::PRED() {
PrimitiveType p(
std::make_shared<PrimitiveType::Impl>(PrimitiveType::Impl::pType::PRED));
return p;
}
PrimitiveType PrimitiveType::S8() {
PrimitiveType p(
std::make_shared<PrimitiveType::Impl>(PrimitiveType::Impl::pType::S8));
return p;
}
PrimitiveType PrimitiveType::S16() {
PrimitiveType p(
std::make_shared<PrimitiveType::Impl>(PrimitiveType::Impl::pType::S16));
return p;
}
PrimitiveType PrimitiveType::F32() {
PrimitiveType p(
std::make_shared<PrimitiveType::Impl>(PrimitiveType::Impl::pType::F32));
return p;
}
PrimitiveType PrimitiveType::S32() {
PrimitiveType p(
std::make_shared<PrimitiveType::Impl>(PrimitiveType::Impl::pType::S32));
return p;
}
PrimitiveType PrimitiveType::S64() {
PrimitiveType p(
std::make_shared<PrimitiveType::Impl>(PrimitiveType::Impl::pType::S64));
return p;
}
Shape::Shape(std::vector<int64_t> dims)
: impl_(std::make_shared<Shape::Impl>(dims)) {}
2021-08-17 11:28:17 +08:00
std::vector<int64_t> Shape::GetDims() { return impl_->GetDims(); }
2021-08-13 15:05:10 +08:00
Type::Type(Shape& shape, PrimitiveType& primitiveType)
: impl_(std::make_shared<Type::Impl>(shape, primitiveType)) {}
2021-08-11 10:46:07 +08:00
Integer::Integer(int value) : impl_(std::make_shared<Integer::Impl>(value)) {}
Integer::Integer(int64_t value)
: impl_(std::make_shared<Integer::Impl>(value)) {}
2021-08-13 15:05:10 +08:00
Float::Float(float value) : impl_(std::make_shared<Float::Impl>(value)) {}
Float::Float(double value) : impl_(std::make_shared<Float::Impl>(value)) {}
int64_t Array::GetSize() { return impl_->GetSize(); }
PrimitiveType Array::GetType() { return impl_->GetType(); }
Array::Array(std::vector<int> value)
: impl_(std::make_shared<Array::Impl>(value)) {}
Array::Array(std::vector<int64_t> value)
: impl_(std::make_shared<Array::Impl>(value)) {}
Array::Array(std::vector<std::string> value)
: impl_(std::make_shared<Array::Impl>(value)) {}
2021-08-17 11:28:17 +08:00
// Tensor::Tensor(Shape& shape, PrimitiveType& primitiveType, const void* value)
// : impl_(std::make_shared<Impl>(shape, primitiveType, value)) {}
2021-08-13 15:05:10 +08:00
Shape Tensor::GetShape() { return impl_->GetShape(); }
2021-08-17 11:28:17 +08:00
// PrimitiveType Tensor::GetType() { return impl_->GetType(); }
Tensor::Tensor(Shape& shape, std::vector<int> value)
: impl_(std::make_shared<Tensor::Impl>(shape, value)) {}
Tensor::Tensor(Shape& shape, std::vector<int64_t> value)
: impl_(std::make_shared<Tensor::Impl>(shape, value)) {}
Tensor::Tensor(Shape& shape, std::vector<float> value)
: impl_(std::make_shared<Tensor::Impl>(shape, value)) {}
2021-08-13 15:05:10 +08:00
TensorInt::TensorInt(Shape& shape, PrimitiveType& primitiveType)
: impl_(std::make_shared<Impl>(shape, primitiveType)) {}
Shape TensorInt::GetShape() { return impl_->GetShape(); }
PrimitiveType TensorInt::GetType() { return impl_->GetType(); }
ChannelHandle::ChannelHandle()
: impl_(std::make_shared<ChannelHandle::Impl>()) {}
ConvDimensionNumbers::ConvDimensionNumbers()
: impl_(std::make_shared<ConvDimensionNumbers::Impl>()) {}
DotDimensionNumbers::DotDimensionNumbers()
: impl_(std::make_shared<DotDimensionNumbers::Impl>()) {}
GatherDimensionNumbers::GatherDimensionNumbers()
: impl_(std::make_shared<GatherDimensionNumbers::Impl>()) {}
ScatterDimensionNumbers::ScatterDimensionNumbers()
: impl_(std::make_shared<ScatterDimensionNumbers::Impl>()) {}
2021-08-11 10:46:07 +08:00
} // namespace builder