Skip to content

Arm backend: Add CEIL Operator #9267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
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
1 change: 1 addition & 0 deletions backends/arm/_passes/insert_table_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class InsertTableOpsPass(ExportPass):
"""

table_ops: Dict[EdgeOpOverload, Callable[[torch.Tensor], torch.Tensor]] = {
exir_ops.edge.aten.ceil.default: torch.ceil,
exir_ops.edge.aten.exp.default: torch.exp,
exir_ops.edge.aten.floor.default: torch.floor,
exir_ops.edge.aten.log.default: torch.log,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def is_node_supported(
exir_ops.edge.aten.bitwise_xor.Tensor,
exir_ops.edge.aten.expand_copy.default,
exir_ops.edge.aten.cat.default,
exir_ops.edge.aten.ceil.default,
exir_ops.edge.aten.clamp.default,
exir_ops.edge.aten.bmm.default,
exir_ops.edge.aten.permute_copy.default,
Expand Down
1 change: 1 addition & 0 deletions backends/arm/operators/ops_unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ def define_node(
register_node_visitor(UnaryOperator)


unary_operator_factory("aten.ceil.default", TosaOp.Op().CEIL)
unary_operator_factory("aten.floor.default", TosaOp.Op().FLOOR)
unary_operator_factory("aten.logical_not.default", TosaOp.Op().LOGICAL_NOT)
1 change: 1 addition & 0 deletions backends/arm/quantizer/quantization_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def _match_pattern(

_one_to_one = [
torch.ops.aten.abs.default,
torch.ops.aten.ceil.default,
torch.ops.aten.exp.default,
torch.ops.aten.floor.default,
torch.ops.aten.log.default,
Expand Down
82 changes: 0 additions & 82 deletions backends/arm/test/ops/test_floor.py

This file was deleted.

153 changes: 153 additions & 0 deletions backends/arm/test/ops/test_unary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Copyright 2025 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.


from typing import Tuple

import torch
from executorch.backends.arm.test import common
from executorch.backends.arm.test.tester.test_pipeline import (
EthosU55PipelineBI,
EthosU85PipelineBI,
TosaPipelineBI,
TosaPipelineMI,
)


input_t1 = Tuple[torch.Tensor] # Input x


class Ceil(torch.nn.Module):
def forward(self, x: torch.Tensor):
return torch.ceil(x)

op_name = "ceil"
aten_op = "torch.ops.aten.ceil.default"
exir_op = "executorch_exir_dialects_edge__ops_aten_ceil_default"


class Floor(torch.nn.Module):
def forward(self, x: torch.Tensor):
return torch.floor(x)

op_name = "floor"
aten_op = "torch.ops.aten.floor.default"
exir_op = "executorch_exir_dialects_edge__ops_aten_floor_default"


zeros = torch.zeros(1, 10, 10, 10)
ones = torch.ones(10, 10, 10)
rand = torch.rand(10, 10) - 0.5
randn_pos = torch.randn(1, 4, 4, 4) + 10
randn_neg = torch.randn(1, 4, 4, 4) - 10
ramp = torch.arange(-16, 16, 0.2)


test_data = {
"ceil_zeros": (
Ceil(),
zeros,
),
"floor_zeros": (
Floor(),
zeros,
),
"ceil_ones": (
Ceil(),
ones,
),
"floor_ones": (
Floor(),
ones,
),
"ceil_rand": (
Ceil(),
rand,
),
"floor_rand": (
Floor(),
rand,
),
"ceil_randn_pos": (
Ceil(),
randn_pos,
),
"floor_randn_pos": (
Floor(),
randn_pos,
),
"ceil_randn_neg": (
Ceil(),
randn_neg,
),
"floor_randn_neg": (
Floor(),
randn_neg,
),
"ceil_ramp": (
Ceil(),
ramp,
),
"floor_ramp": (
Floor(),
ramp,
),
}


@common.parametrize("test_data", test_data)
def test_unary_tosa_MI(test_data: input_t1):
module = test_data[0]
pipeline = TosaPipelineMI[input_t1](
module, (test_data[1],), module.aten_op, module.exir_op
)
pipeline.run()


@common.parametrize("test_data", test_data)
def test_unary_tosa_BI(test_data: input_t1):
module = test_data[0]
pipeline = TosaPipelineBI[input_t1](
module, (test_data[1],), module.aten_op, module.exir_op
)
pipeline.run()


@common.parametrize("test_data", test_data)
def test_unary_u55_BI(test_data: input_t1):
module = test_data[0]
pipeline = EthosU55PipelineBI[input_t1](
module, (test_data[1],), module.aten_op, module.exir_op, run_on_fvp=False
)
pipeline.run()


@common.parametrize("test_data", test_data)
def test_unary_u85_BI(test_data: input_t1):
module = test_data[0]
pipeline = EthosU85PipelineBI[input_t1](
module, (test_data[1],), module.aten_op, module.exir_op, run_on_fvp=False
)
pipeline.run()


@common.parametrize("test_data", test_data)
@common.SkipIfNoCorstone300
def test_unary_u55_BI_on_fvp(test_data: input_t1):
module = test_data[0]
pipeline = EthosU55PipelineBI[input_t1](
module, (test_data[1],), module.aten_op, module.exir_op, run_on_fvp=True
)
pipeline.run()


@common.parametrize("test_data", test_data)
@common.SkipIfNoCorstone320
def test_unary_u85_BI_on_fvp(test_data: input_t1):
module = test_data[0]
pipeline = EthosU85PipelineBI[input_t1](
module, (test_data[1],), module.aten_op, module.exir_op, run_on_fvp=True
)
pipeline.run()
Loading