Skip to content

Commit e4fdee4

Browse files
thomasywangfacebook-github-bot
authored andcommitted
Use compact reshaping in cast (#1281)
Summary: Use the algorithm from D82697968 Differential Revision: D82831565
1 parent 21840fd commit e4fdee4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

hyperactor_mesh/src/actor_mesh.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ use ndslice::Shape;
4141
use ndslice::ShapeError;
4242
use ndslice::SliceError;
4343
use ndslice::reshape::Limit;
44+
use ndslice::reshape::ReshapeError;
4445
use ndslice::reshape::ReshapeSliceExt;
46+
use ndslice::reshape::reshape_selection;
4547
use ndslice::selection;
4648
use ndslice::selection::EvalOpts;
4749
use ndslice::selection::ReifySlice;
@@ -121,12 +123,7 @@ where
121123

122124
(
123125
if reshaped_slice != *slice_of_root {
124-
Selection::of_ranks(
125-
&reshaped_slice,
126-
&selection_of_root
127-
.eval(&selection::EvalOpts::strict(), slice_of_root)?
128-
.collect::<BTreeSet<_>>(),
129-
)?
126+
reshape_selection(selection_of_root, root_mesh_shape.slice(), &reshaped_slice)?
130127
} else {
131128
selection_of_root
132129
},
@@ -494,6 +491,9 @@ pub enum CastError {
494491

495492
#[error(transparent)]
496493
Other(#[from] anyhow::Error),
494+
495+
#[error(transparent)]
496+
ReshapeError(#[from] ReshapeError),
497497
}
498498

499499
// This has to be compiled outside of test mode because the bootstrap binary

0 commit comments

Comments
 (0)