Add e2e demo test in dump comparator (#21031)
This commit is contained in:
@@ -261,24 +261,6 @@ def _compute_dependent_axes(
|
||||
)
|
||||
|
||||
|
||||
def _is_dependent_axis(
|
||||
parallel_infos: list[dict[ParallelAxis, AxisInfo]],
|
||||
*,
|
||||
parent: ParallelAxis,
|
||||
child: ParallelAxis,
|
||||
) -> bool:
|
||||
"""True if child's rank is uniquely determined by parent's rank."""
|
||||
parent_rank_to_child_rank: dict[int, int] = {}
|
||||
for info in parallel_infos:
|
||||
if parent not in info or child not in info:
|
||||
continue
|
||||
parent_rank = info[parent].axis_rank
|
||||
child_rank = info[child].axis_rank
|
||||
if parent_rank_to_child_rank.setdefault(parent_rank, child_rank) != child_rank:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _is_jointly_determined(
|
||||
parallel_infos: list[dict[ParallelAxis, AxisInfo]],
|
||||
*,
|
||||
@@ -320,6 +302,24 @@ def _is_jointly_determined(
|
||||
return bool(mapping)
|
||||
|
||||
|
||||
def _is_dependent_axis(
|
||||
parallel_infos: list[dict[ParallelAxis, AxisInfo]],
|
||||
*,
|
||||
parent: ParallelAxis,
|
||||
child: ParallelAxis,
|
||||
) -> bool:
|
||||
"""True if child's rank is uniquely determined by parent's rank."""
|
||||
parent_rank_to_child_rank: dict[int, int] = {}
|
||||
for info in parallel_infos:
|
||||
if parent not in info or child not in info:
|
||||
continue
|
||||
parent_rank = info[parent].axis_rank
|
||||
child_rank = info[child].axis_rank
|
||||
if parent_rank_to_child_rank.setdefault(parent_rank, child_rank) != child_rank:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _group_and_project(
|
||||
*,
|
||||
current_coords: _CoordsList,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import __future__
|
||||
|
||||
import importlib
|
||||
import inspect
|
||||
import textwrap
|
||||
@@ -85,7 +87,12 @@ def patch_function(
|
||||
if preamble.strip():
|
||||
modified_source = _insert_preamble(source=modified_source, preamble=preamble)
|
||||
|
||||
code: types.CodeType = compile(modified_source, inspect.getfile(target), "exec")
|
||||
code: types.CodeType = compile(
|
||||
modified_source,
|
||||
inspect.getfile(target),
|
||||
"exec",
|
||||
flags=__future__.annotations.compiler_flag,
|
||||
)
|
||||
temp_namespace: dict[str, Any] = {}
|
||||
exec(code, target.__globals__, temp_namespace)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user