105 lines
3.8 KiB
C++
105 lines
3.8 KiB
C++
#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 {
|
|
|
|
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)) {}
|
|
std::vector<int64_t> Shape::GetDims() { return impl_->GetDims(); }
|
|
|
|
Type::Type(Shape& shape, PrimitiveType& primitiveType)
|
|
: impl_(std::make_shared<Type::Impl>(shape, primitiveType)) {}
|
|
|
|
Integer::Integer(int value) : impl_(std::make_shared<Integer::Impl>(value)) {}
|
|
Integer::Integer(int64_t value)
|
|
: impl_(std::make_shared<Integer::Impl>(value)) {}
|
|
|
|
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)) {}
|
|
|
|
// Tensor::Tensor(Shape& shape, PrimitiveType& primitiveType, const void* value)
|
|
// : impl_(std::make_shared<Impl>(shape, primitiveType, value)) {}
|
|
Shape Tensor::GetShape() { return impl_->GetShape(); }
|
|
// 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)) {}
|
|
|
|
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>()) {}
|
|
|
|
} // namespace builder
|