Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/Dialect/Shape/IR/Shape.cpp
Show All 10 Lines | |||||
#include "mlir/Dialect/StandardOps/IR/Ops.h" | #include "mlir/Dialect/StandardOps/IR/Ops.h" | ||||
#include "mlir/Dialect/Traits.h" | #include "mlir/Dialect/Traits.h" | ||||
#include "mlir/IR/Builders.h" | #include "mlir/IR/Builders.h" | ||||
#include "mlir/IR/DialectImplementation.h" | #include "mlir/IR/DialectImplementation.h" | ||||
#include "mlir/IR/PatternMatch.h" | #include "mlir/IR/PatternMatch.h" | ||||
#include "mlir/IR/StandardTypes.h" | #include "mlir/IR/StandardTypes.h" | ||||
#include "mlir/Transforms/InliningUtils.h" | #include "mlir/Transforms/InliningUtils.h" | ||||
#include "llvm/ADT/SmallString.h" | #include "llvm/ADT/SmallString.h" | ||||
#include "llvm/ADT/TypeSwitch.h" | |||||
#include "llvm/Support/raw_ostream.h" | #include "llvm/Support/raw_ostream.h" | ||||
using namespace mlir; | using namespace mlir; | ||||
using namespace mlir::shape; | using namespace mlir::shape; | ||||
namespace { | namespace { | ||||
#include "ShapeCanonicalization.inc" | #include "ShapeCanonicalization.inc" | ||||
} | } | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | if (keyword == "witness") | ||||
return WitnessType::get(getContext()); | return WitnessType::get(getContext()); | ||||
parser.emitError(parser.getNameLoc(), "unknown shape type: ") << keyword; | parser.emitError(parser.getNameLoc(), "unknown shape type: ") << keyword; | ||||
return Type(); | return Type(); | ||||
} | } | ||||
/// Print a type registered to this dialect. | /// Print a type registered to this dialect. | ||||
void ShapeDialect::printType(Type type, DialectAsmPrinter &os) const { | void ShapeDialect::printType(Type type, DialectAsmPrinter &os) const { | ||||
switch (type.getKind()) { | TypeSwitch<Type>(type) | ||||
case ShapeTypes::Component: | .Case<ComponentType>([&](Type) { os << "component"; }) | ||||
os << "component"; | .Case<ElementType>([&](Type) { os << "element"; }) | ||||
return; | .Case<ShapeType>([&](Type) { os << "shape"; }) | ||||
case ShapeTypes::Element: | .Case<SizeType>([&](Type) { os << "size"; }) | ||||
os << "element"; | .Case<ValueShapeType>([&](Type) { os << "value_shape"; }) | ||||
return; | .Case<WitnessType>([&](Type) { os << "witness"; }) | ||||
case ShapeTypes::Size: | .Default([](Type) { llvm_unreachable("unexpected 'shape' type kind"); }); | ||||
os << "size"; | |||||
return; | |||||
case ShapeTypes::Shape: | |||||
os << "shape"; | |||||
return; | |||||
case ShapeTypes::ValueShape: | |||||
os << "value_shape"; | |||||
return; | |||||
case ShapeTypes::Witness: | |||||
os << "witness"; | |||||
return; | |||||
default: | |||||
llvm_unreachable("unexpected 'shape' type kind"); | |||||
} | |||||
} | } | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// AnyOp | // AnyOp | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// TODO: Canonicalization should be implemented for shapes that can be | // TODO: Canonicalization should be implemented for shapes that can be | ||||
// determined through mixtures of the known dimensions of the inputs. | // determined through mixtures of the known dimensions of the inputs. | ||||
▲ Show 20 Lines • Show All 788 Lines • Show Last 20 Lines |