Skip to content

Commit 91043d7

Browse files
mwhittakerGoogle-ML-Automation
authored andcommitted
Add stablehlo.async_start and stablehlo.async_done.
See openxla/stablehlo#2897 for context. This CL introduces a `stablehlo.future` type and `stablehlo.async_start` and `stablehlo.async_done`. It does not add any translation for them. That will come in a later change. I also did not make `async_start` and `async_done` variadic for now, even though some collectives are variadic. We can add support for that later if we need it. PiperOrigin-RevId: 874740969
1 parent d9d2a0f commit 91043d7

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

xla/hlo/translate/mhlo_to_hlo/gen_hlo_op_writer.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ defvar CustomHloConverterOps = [
5555
StableHLO_AllGatherOp,
5656
StableHLO_AllReduceOp,
5757
StableHLO_AllToAllOp,
58+
StableHLO_AsyncDoneOp,
59+
StableHLO_AsyncStartOp,
5860
StableHLO_BatchNormGradOp,
5961
StableHLO_BatchNormTrainingOp,
6062
StableHLO_BitcastConvertOp,

xla/hlo/translate/mhlo_to_hlo/mlir_hlo_to_hlo.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3064,6 +3064,16 @@ LogicalResult ExportXlaOp(UniformDequantizeOp op, OpLoweringContext ctx) {
30643064
return failure();
30653065
}
30663066

3067+
LogicalResult ExportXlaOp(AsyncStartOp op, OpLoweringContext ctx) {
3068+
// TODO(mwhittaker): Implement.
3069+
return failure();
3070+
}
3071+
3072+
LogicalResult ExportXlaOp(AsyncDoneOp op, OpLoweringContext ctx) {
3073+
// TODO(mwhittaker): Implement.
3074+
return failure();
3075+
}
3076+
30673077
} // namespace
30683078
} // namespace stablehlo
30693079

xla/mlir_hlo/mhlo/transforms/map_stablehlo_to_hlo_op.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,21 @@ MAP_HLO_TO_HLO_TYPE_REWRITE(AsyncDoneOp)
178178

179179
#undef MAP_HLO_TO_HLO_TYPE_REWRITE
180180

181+
// TODO(mwhittaker): Remove this when we translate async ops between StableHLO
182+
// and MHLO.
183+
#define MAP_STABLEHLO_TO_STABLEHLO_TYPE_REWRITE(OpName) \
184+
template <> \
185+
struct HloToStablehloOpImpl<stablehlo::OpName> { \
186+
using Type = stablehlo::OpName; \
187+
}; \
188+
template <> \
189+
struct StablehloToHloOpImpl<stablehlo::OpName> { \
190+
using Type = stablehlo::OpName; \
191+
};
192+
MAP_STABLEHLO_TO_STABLEHLO_TYPE_REWRITE(AsyncStartOp)
193+
MAP_STABLEHLO_TO_STABLEHLO_TYPE_REWRITE(AsyncDoneOp)
194+
#undef MAP_STABLEHLO_TO_STABLEHLO_TYPE_REWRITE
195+
181196
} // namespace stablehlo
182197
} // namespace mlir
183198

0 commit comments

Comments
 (0)