-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This ensures the check isn't optimized away by the compiler. PiperOrigin-RevId: 680546512
- Loading branch information
1 parent
c464210
commit f810ee8
Showing
25 changed files
with
1,386 additions
and
4,159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
shardy/dialect/sdy/ir/test/named_computation_parse_print.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// RUN: sdy_opt %s 2>&1 | FileCheck %s | ||
|
||
// CHECK-LABEL: func @one_input_output | ||
func.func @one_input_output(%arg0: tensor<8x2xi32>) -> tensor<8x2xi32> { | ||
// CHECK-NEXT: %0 = sdy.named_computation<"foo">(%arg0) (%arg1: tensor<8x2xi32>) { | ||
// CHECK-NEXT: sdy.return %arg1 : tensor<8x2xi32> | ||
// CHECK-NEXT: } : (tensor<8x2xi32>) -> tensor<8x2xi32> | ||
%0 = sdy.named_computation<"foo">(%arg0) (%arg1: tensor<8x2xi32>) { | ||
sdy.return %arg1 : tensor<8x2xi32> | ||
} : (tensor<8x2xi32>) -> tensor<8x2xi32> | ||
return %0 : tensor<8x2xi32> | ||
} | ||
|
||
|
||
// CHECK-LABEL: func @two_inputs_outputs | ||
func.func @two_inputs_outputs(%arg0: tensor<8x2xi32>, %arg1: tensor<4x2xi32>) -> (tensor<8x2xi32>, tensor<4x2xi32>) { | ||
// CHECK-NEXT: %0:2 = sdy.named_computation<"named_computation">(%arg0, %arg1) (%arg2: tensor<8x2xi32>, %arg3: tensor<4x2xi32>) { | ||
//CHECK-NEXT: sdy.return %arg2, %arg3 : tensor<8x2xi32>, tensor<4x2xi32> | ||
// CHECK-NEXT: } : (tensor<8x2xi32>, tensor<4x2xi32>) -> (tensor<8x2xi32>, tensor<4x2xi32>) | ||
%0:2 = sdy.named_computation<"named_computation">(%arg0, %arg1) (%arg2: tensor<8x2xi32>, %arg3: tensor<4x2xi32>) { | ||
sdy.return %arg2, %arg3 : tensor<8x2xi32>, tensor<4x2xi32> | ||
} : (tensor<8x2xi32>, tensor<4x2xi32>) -> (tensor<8x2xi32>, tensor<4x2xi32>) | ||
return %0#0, %0#1 : tensor<8x2xi32>, tensor<4x2xi32> | ||
} |
41 changes: 41 additions & 0 deletions
41
shardy/dialect/sdy/ir/test/named_computation_verification.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// RUN: sdy_opt %s -split-input-file -verify-diagnostics | ||
|
||
func.func @invalid_operand_type(%arg0: tensor<8x2xi32>) -> tensor<8x2xi32> { | ||
// expected-error@+1 {{expected the type of the 0'th block argument to match the type of the corresponding operand: 'tensor<4x2xi32>' vs 'tensor<8x2xi32>'}} | ||
%0 = sdy.named_computation<"bar">(%arg0) (%arg1: tensor<4x2xi32>) { | ||
%1 = stablehlo.custom_call @foo(%arg1) : (tensor<4x2xi32>) -> tensor<8x2xi32> | ||
sdy.return %1 : tensor<8x2xi32> | ||
}: (tensor<8x2xi32>) -> tensor<8x2xi32> | ||
return %0 : tensor<8x2xi32> | ||
} | ||
|
||
// ----- | ||
|
||
func.func @operand_count_mismatch(%arg0: tensor<8x2xi32>) -> tensor<8x2xi32> { | ||
// expected-error@+1 {{number of block arguments must match the number of operands: 2 != 1}} | ||
%0 = sdy.named_computation<"bar">(%arg0) (%arg1: tensor<8x2xi32>, %arg2: tensor<8x2xi32>) { | ||
sdy.return %arg1 : tensor<8x2xi32> | ||
}: (tensor<8x2xi32>) -> tensor<8x2xi32> | ||
return %0 : tensor<8x2xi32> | ||
} | ||
|
||
// ----- | ||
|
||
func.func @invalid_result_type(%arg0: tensor<8x2xi32>) -> tensor<8x2xi32> { | ||
// expected-error@+1 {{expected the type of the 0'th returned value to match the type of the corresponding result: 'tensor<4x2xi32>' vs 'tensor<8x2xi32>'}} | ||
%0 = sdy.named_computation<"bar">(%arg0) (%arg1: tensor<8x2xi32>) { | ||
%1 = stablehlo.custom_call @foo(%arg1) : (tensor<8x2xi32>) -> tensor<4x2xi32> | ||
sdy.return %1 : tensor<4x2xi32> | ||
}: (tensor<8x2xi32>) -> tensor<8x2xi32> | ||
return %0 : tensor<8x2xi32> | ||
} | ||
|
||
// ----- | ||
|
||
func.func @result_count_mismatch(%arg0: tensor<8x2xi32>) -> tensor<8x2xi32> { | ||
// expected-error@+1 {{number of returned values must match the number of results: 2 != 1}} | ||
%0 = sdy.named_computation<"bar">(%arg0) (%arg1: tensor<8x2xi32>) { | ||
sdy.return %arg1, %arg1 : tensor<8x2xi32>, tensor<8x2xi32> | ||
}: (tensor<8x2xi32>) -> tensor<8x2xi32> | ||
return %0 : tensor<8x2xi32> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
shardy/dialect/sdy/transforms/export/insert_explicit_reshards.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* Copyright 2024 The Shardy Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
==============================================================================*/ | ||
|
||
#include <cassert> | ||
|
||
#include "mlir/Dialect/Func/IR/FuncOps.h" // IWYU pragma: keep | ||
#include "mlir/Pass/Pass.h" // IWYU pragma: keep | ||
#include "shardy/dialect/sdy/ir/dialect.h" // IWYU pragma: keep | ||
|
||
namespace mlir { | ||
namespace sdy { | ||
|
||
#define GEN_PASS_DEF_INSERTEXPLICITRESHARDSPASS | ||
#include "shardy/dialect/sdy/transforms/export/passes.h.inc" | ||
|
||
namespace { | ||
|
||
struct InsertExplicitReshardsPass | ||
: public impl::InsertExplicitReshardsPassBase<InsertExplicitReshardsPass> { | ||
using InsertExplicitReshardsPassBase::InsertExplicitReshardsPassBase; | ||
|
||
void runOnOperation() final { | ||
// Not ready yet. It is currently a no-op. | ||
} | ||
}; | ||
|
||
} // namespace | ||
|
||
} // namespace sdy | ||
} // namespace mlir |
Oops, something went wrong.