Skip to content

Commit

Permalink
[NFC][Mosaic TPU] Separate out retiling from relayout
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 658335679
  • Loading branch information
apaszke authored and jax authors committed Aug 1, 2024
1 parent 0734345 commit 0307438
Show file tree
Hide file tree
Showing 3 changed files with 211 additions and 183 deletions.
12 changes: 11 additions & 1 deletion jaxlib/mosaic/dialect/tpu/layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ llvm::hash_code hash_value(const VectorLayout& layout) {
return llvm::hash_value(layout.as_tuple());
}

std::ostream &operator<<(std::ostream &os, VectorLayout::ImplicitDim dim) {
template <typename Stream>
Stream& printImplicitDim(Stream& os, VectorLayout::ImplicitDim dim) {
switch (dim) {
case VectorLayout::ImplicitDim::kNone:
os << "none";
Expand All @@ -728,6 +729,15 @@ std::ostream &operator<<(std::ostream &os, VectorLayout::ImplicitDim dim) {
return os;
}

std::ostream& operator<<(std::ostream& os, VectorLayout::ImplicitDim dim) {
return printImplicitDim(os, dim);
}

mlir::Diagnostic& operator<<(mlir::Diagnostic& diag,
VectorLayout::ImplicitDim dim) {
return printImplicitDim(diag, dim);
}

std::optional<Layout> parseLayout(mlir::AsmParser& parser) {
std::string layout_str;
if (failed(parser.parseString(&layout_str))) {
Expand Down
2 changes: 2 additions & 0 deletions jaxlib/mosaic/dialect/tpu/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Layout &v);
llvm::hash_code hash_value(const VectorLayout &layout);
mlir::Diagnostic &operator<<(mlir::Diagnostic &diag, const Layout &v);
std::ostream &operator<<(std::ostream &os, VectorLayout::ImplicitDim dim);
mlir::Diagnostic &operator<<(mlir::Diagnostic &diag,
VectorLayout::ImplicitDim dim);

std::optional<Layout> parseLayout(mlir::AsmParser &parser);

Expand Down
Loading

0 comments on commit 0307438

Please sign in to comment.