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
4 changes: 3 additions & 1 deletion backends/arm/operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@
op_avg_pool2d,
op_bmm,
op_cat,
op_ceil,
op_clamp,
op_constant_pad_nd,
op_conv2d,
op_cos,
op_eq,
op_erf,
op_exp,
op_floor,
op_ge,
op_gt,
op_index_select,
op_index_tensor,
op_le,
op_log,
op_logical_not,
op_lt,
op_max_pool2d,
op_maximum,
Expand Down Expand Up @@ -57,5 +60,4 @@
op_where,
ops_binary,
ops_identity,
ops_unary,
)
54 changes: 54 additions & 0 deletions backends/arm/operators/op_ceil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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 Any, List

import torch.fx

from executorch.backends.arm.operators.node_visitor import (
NodeVisitor,
register_node_visitor,
)
from executorch.backends.arm.operators.operator_validation_utils import (
validate_num_inputs,
validate_same_dtype,
validate_valid_dtype,
)
from executorch.backends.arm.tosa import TosaSpecification

from executorch.backends.arm.tosa.mapping import TosaArg


@register_node_visitor
class CeilVisitor(NodeVisitor):
target = "aten.ceil.default"

# INT case should be handled by op_table
tosa_specs = [TosaSpecification.create_from_string("TOSA-1.0+FP")]

def __init__(self, *args):
super().__init__(*args)

def define_node(
self,
node: torch.fx.Node,
tosa_graph: Any,
inputs: List[TosaArg],
output: TosaArg,
) -> None:
import serializer.tosa_serializer as ts # type: ignore # noqa: F401

validate_num_inputs(self.target, inputs, 1)
validate_same_dtype(self.target, [*inputs, output], ts)
validate_valid_dtype(
self.target,
inputs[0],
ts.DType.FP32,
output.tosa_spec,
)

self._serialize_operator(
node, tosa_graph, ts.TosaOp.Op().CEIL, [inputs[0].name], [output.name]
)
54 changes: 54 additions & 0 deletions backends/arm/operators/op_floor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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 Any, List

import torch.fx

from executorch.backends.arm.operators.node_visitor import (
NodeVisitor,
register_node_visitor,
)
from executorch.backends.arm.operators.operator_validation_utils import (
validate_num_inputs,
validate_same_dtype,
validate_valid_dtype,
)
from executorch.backends.arm.tosa import TosaSpecification

from executorch.backends.arm.tosa.mapping import TosaArg


@register_node_visitor
class FloorVisitor(NodeVisitor):
target = "aten.floor.default"

# INT case should be handled by op_table
tosa_specs = [TosaSpecification.create_from_string("TOSA-1.0+FP")]

def __init__(self, *args):
super().__init__(*args)

def define_node(
self,
node: torch.fx.Node,
tosa_graph: Any,
inputs: List[TosaArg],
output: TosaArg,
) -> None:
import serializer.tosa_serializer as ts # type: ignore # noqa: F401

validate_num_inputs(self.target, inputs, 1)
validate_same_dtype(self.target, [*inputs, output], ts)
validate_valid_dtype(
self.target,
inputs[0],
ts.DType.FP32,
output.tosa_spec,
)

self._serialize_operator(
node, tosa_graph, ts.TosaOp.Op().FLOOR, [inputs[0].name], [output.name]
)
59 changes: 59 additions & 0 deletions backends/arm/operators/op_logical_not.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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 Any, List

import torch.fx

from executorch.backends.arm.operators.node_visitor import (
NodeVisitor,
register_node_visitor,
)
from executorch.backends.arm.operators.operator_validation_utils import (
validate_num_inputs,
validate_same_dtype,
validate_valid_dtype,
)
from executorch.backends.arm.tosa import TosaSpecification
from executorch.backends.arm.tosa.mapping import TosaArg


@register_node_visitor
class LogicalNotVisitor(NodeVisitor):
target = "aten.logical_not.default"

tosa_specs = [
TosaSpecification.create_from_string("TOSA-1.0+INT"),
TosaSpecification.create_from_string("TOSA-1.0+FP"),
]

def __init__(self, *args):
super().__init__(*args)

def define_node(
self,
node: torch.fx.Node,
tosa_graph: Any,
inputs: List[TosaArg],
output: TosaArg,
) -> None:
import serializer.tosa_serializer as ts # type: ignore # noqa: F401

validate_num_inputs(self.target, inputs, 1)
validate_same_dtype(self.target, [*inputs, output], ts)
validate_valid_dtype(
self.target,
[*inputs, output],
[ts.DType.BOOL],
output.tosa_spec,
)

self._serialize_operator(
node,
tosa_graph,
ts.TosaOp.Op().LOGICAL_NOT,
[inputs[0].name],
[output.name],
)
68 changes: 0 additions & 68 deletions backends/arm/operators/ops_unary.py

This file was deleted.

Loading