Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions backends/arm/scripts/docgen/generate_op_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Examples:
python backends/arm/scripts/docgen/generate_op_support.py --backend vgf
python backends/arm/scripts/docgen/generate_op_support.py --backend u55
python backends/arm/scripts/docgen/generate_op_support.py --backend u85
python backends/arm/scripts/docgen/generate_op_support.py --backend u55 --debug --html
python backends/arm/scripts/docgen/generate_op_support.py --backend vgf --check --strict-ast

Expand Down Expand Up @@ -104,6 +105,22 @@ class BackendConfig:
filter_u55_unsupported_ops=True,
max_missing_profile_cells=4,
),
"u85": BackendConfig(
key="u85",
name="Ethos-U85",
pipeline_class_names=frozenset({"EthosU85PipelineINT"}),
pipeline_label="EthosU85PipelineINT",
tosa_spec="TOSA-1.0+INT+int16+int4+cf",
default_output=Path("docs/source/backends/arm-ethos-u/U85_op_support.md"),
quantize_keyword=None,
quantize_default=True,
default_profile="INT",
support_profile_order=("INT",),
# A missing Corstone-320 FVP is infrastructure, not evidence that the
# operator itself is unsupported.
infrastructure_xfail_markers=frozenset({"XfailIfNoCorstone320"}),
max_missing_profile_cells=10,
),
}

# Compatibility globals used by the mature scanner implementation. They are
Expand Down Expand Up @@ -418,6 +435,25 @@ def _activate_backend(backend: str | BackendConfig) -> BackendConfig:
},
}

# Existing U85 runtime tests below intentionally suppress direct ATen/Edge
# assertions because quantization/decomposition changes the graph. They still
# provide positive runtime coverage for the exported operator.
U85_EXPLICIT_BACKEND_COVERAGE: dict[tuple[str, str], dict[str, set[str]]] = {
(
"backends/arm/test/ops/test_div_tensor_mode.py",
"test_div_tensor_mode_u85_INT",
): {
"INT": {"torch.ops.aten.div.Tensor_mode"},
},
(
"backends/arm/test/ops/test_silu.py",
"test_silu_u85_INT",
): {
"INT": {"torch.ops.aten.silu.default"},
},
}


# These exported operators pass a generic TOSA positive-support declaration,
# but their actual U55 lowering path reaches an unsupported operation or a
# restriction that cannot support the general exported operator. Keep these
Expand All @@ -438,6 +474,8 @@ def _active_explicit_backend_coverage() -> dict[tuple[str, str], dict[str, set[s
return VGF_EXPLICIT_BACKEND_COVERAGE
if ACTIVE_BACKEND_KEY == "u55":
return U55_EXPLICIT_BACKEND_COVERAGE
if ACTIVE_BACKEND_KEY == "u85":
return U85_EXPLICIT_BACKEND_COVERAGE
return {}


Expand Down Expand Up @@ -2369,6 +2407,9 @@ def _collect_backend_custom_partition_ops(
to the profiles for which they are actually registered.

"""
if ACTIVE_BACKEND_KEY != "vgf":
return {}

from executorch.backends.arm.vgf import VgfCompileSpec, VgfPartitioner

enabled_profiles = {
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/scripts/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ DOCGEN_OUTPUTS=(
OP_SUPPORT_SCRIPT="backends/arm/scripts/docgen/generate_op_support.py"
VGF_OP_SUPPORT_OUTPUT="docs/source/backends/arm-vgf/VGF_op_support.md"
U55_OP_SUPPORT_OUTPUT="docs/source/backends/arm-ethos-u/U55_op_support.md"
U85_OP_SUPPORT_OUTPUT="docs/source/backends/arm-ethos-u/U85_op_support.md"

RUN_DOCGEN=0

Expand Down Expand Up @@ -353,6 +354,7 @@ fi

run_op_support_checks "vgf" "VGF" "$VGF_OP_SUPPORT_OUTPUT"
run_op_support_checks "u55" "Ethos-U55" "$U55_OP_SUPPORT_OUTPUT"
run_op_support_checks "u85" "Ethos-U85" "$U85_OP_SUPPORT_OUTPUT"
run_public_api_validator

if [[ $FAILED ]]; then
Expand Down
73 changes: 73 additions & 0 deletions backends/arm/test/misc/test_docgen_op_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,79 @@ def test_u55_infrastructure_xfail_is_not_treated_as_unsupported() -> None:
docgen._activate_backend(original)


def test_u85_backend_configuration_and_profile() -> None:
original = docgen.ACTIVE_BACKEND_KEY
try:
config = docgen._activate_backend("u85")
assert config.pipeline_class_names == frozenset({"EthosU85PipelineINT"})
assert docgen.BACKEND_NAME == "Ethos-U85"
assert docgen.BACKEND_TOSA_SPEC == "TOSA-1.0+INT+int16+int4+cf"
assert docgen.DEFAULT_OUTPUT == Path(
"docs/source/backends/arm-ethos-u/U85_op_support.md"
)
assert docgen.SUPPORT_PROFILE_ORDER == ["INT"]

stmt = ast.parse("EthosU85PipelineINT(quantize=False)").body[0]
assert isinstance(stmt, ast.Expr)
call = stmt.value
assert isinstance(call, ast.Call)
# U85 is integer-only; an irrelevant quantize kwarg cannot turn it FP.
assert docgen._pipeline_profile(call) == "INT"
finally:
docgen._activate_backend(original)


def test_u85_infrastructure_xfail_is_not_treated_as_unsupported() -> None:
original = docgen.ACTIVE_BACKEND_KEY
try:
docgen._activate_backend("u85")
tree = ast.parse(
"@common.XfailIfNoCorstone320\n" "def test_u85():\n" " pass\n"
)
function = tree.body[0]
assert isinstance(function, ast.FunctionDef)
assert not docgen._function_is_skipped_or_xfailed(function)

semantic_tree = ast.parse(
"@pytest.mark.xfail(reason='unsupported')\n"
"def test_u85():\n"
" pass\n"
)
semantic_function = semantic_tree.body[0]
assert isinstance(semantic_function, ast.FunctionDef)
assert docgen._function_is_skipped_or_xfailed(semantic_function)
finally:
docgen._activate_backend(original)


def test_u85_explicit_coverage_attribution() -> None:
original = docgen.ACTIVE_BACKEND_KEY
try:
docgen._activate_backend("u85")
coverage = docgen._active_explicit_backend_coverage()

assert coverage[
(
"backends/arm/test/ops/test_div_tensor_mode.py",
"test_div_tensor_mode_u85_INT",
)
]["INT"] == {"torch.ops.aten.div.Tensor_mode"}
assert coverage[("backends/arm/test/ops/test_silu.py", "test_silu_u85_INT")][
"INT"
] == {"torch.ops.aten.silu.default"}
finally:
docgen._activate_backend(original)


def test_non_vgf_backend_does_not_collect_vgf_custom_partition_ops() -> None:
original = docgen.ACTIVE_BACKEND_KEY
try:
docgen._activate_backend("u85")
assert docgen._collect_backend_custom_partition_ops(object()) == {} # type: ignore[arg-type]
finally:
docgen._activate_backend(original)


def test_backend_registry_filter_removes_unconditional_rejections(
monkeypatch: pytest.MonkeyPatch,
) -> None:
Expand Down
Loading
Loading