Skip to content

Add a target rule for ops_registrations #5083

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

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 12 additions & 0 deletions backends/cadence/aot/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ python_library(
],
)

python_library(
name = "ops_registrations",
srcs = [
"ops_registrations.py",
],
deps = [
":utils",
"//caffe2:torch",
"//executorch/exir:scalar_type",
],
)

export_file(name = "functions.yaml")

executorch_generated_lib(
Expand Down
16 changes: 9 additions & 7 deletions backends/cadence/aot/ops_registrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict

from math import prod
from typing import Optional, Tuple

Expand Down Expand Up @@ -74,8 +76,8 @@ def quantize_per_tensor_meta(
zero_point: int,
quant_min: int,
quant_max: int,
dtype: ScalarType,
):
dtype: torch.dtype,
) -> torch.Tensor:
return input.new_empty(input.size(), dtype=dtype)


Expand All @@ -86,8 +88,8 @@ def dequantize_per_tensor_meta(
zero_point: int,
quant_min: int,
quant_max: int,
dtype: ScalarType,
):
dtype: torch.dtype,
) -> torch.Tensor:
return input.new_empty(input.size(), dtype=torch.float)


Expand All @@ -102,7 +104,7 @@ def quantized_linear_meta(
out_shift: torch.Tensor,
out_zero_point: int,
offset: Optional[torch.Tensor],
):
) -> torch.Tensor:
# src comes in shape [leading_dims, in_dim]
# weight comes in shape [out_dim, in_dim]
# output comes in empty with shape [leading_dims, out_dim]
Expand Down Expand Up @@ -162,7 +164,7 @@ def quantized_layer_norm_meta(
eps: float,
output_scale: float,
output_zero_point: int,
):
) -> torch.Tensor:
return input.new_empty(input.size(), dtype=torch.uint8)


Expand All @@ -173,7 +175,7 @@ def quantized_relu_meta(
out_zero_point: int,
out_multiplier: torch.Tensor,
out_shift: torch.Tensor,
):
) -> torch.Tensor:
return X.new_empty(X.size(), dtype=torch.uint8)


Expand Down