Skip to content

Commit 213a00f

Browse files
committed
Update on "[ET-VK] Using push constants for unary op."
This diff transitions the unary op to utilize push constants, replacing the previous ubo implementation. Differential Revision: [D77706459](https://our.internmc.facebook.com/intern/diff/D77706459/) [ghstack-poisoned]
2 parents 6e73bca + 129de99 commit 213a00f

File tree

97 files changed

+1616
-887
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1616
-887
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7cda4017ddda554752e89069ae205be5e8388f59
1+
9b498d3bb28b8e3411ce464dd2755c5b96d92c8f

.ci/scripts/check_c10_sync.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ pushd pytorch
1212
git checkout "$pytorch_pin"
1313
popd
1414
"$(dirname "${BASH_SOURCE[0]}")"/compare_dirs.sh runtime/core/portable_type/c10/c10 pytorch/c10
15-
"$(dirname "${BASH_SOURCE[0]}")"/compare_dirs.sh runtime/core/portable_type/c10/torch/headeronly pytorch/torch/headeronly
15+
"$(dirname "${BASH_SOURCE[0]}")"/compare_dirs.sh runtime/core/portable_type/c10/torch/standalone pytorch/torch/standalone

backends/arm/_passes/arm_pass_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# LICENSE file in the root directory of this source tree.
77

88
# pyre-unsafe
9+
10+
import executorch.backends.arm.tosa.dialect # noqa: unused
911
from executorch.backends.arm._passes import (
1012
AddBiasPass,
1113
AnnotateChannelsLastDimOrder,

backends/arm/test/passes/test_decorate_fp32_to_int32_casting_pass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import Tuple
77

88
import torch
9-
from executorch.backends.arm.test import common
9+
from executorch.backends.arm.test import common, conftest
1010

1111
from executorch.backends.arm.test.tester.test_pipeline import (
1212
OpNotSupportedPipeline,
@@ -55,6 +55,7 @@ def test_decorate_fp32_to_int32_casting_tosa_MI(test_data: Tuple):
5555
(test_tensor,),
5656
aten_op=[],
5757
exir_op=[],
58+
run_on_tosa_ref_model=conftest.is_option_enabled("tosa_ref_model"),
5859
)
5960
pipeline.run()
6061

backends/cadence/aot/functions_hifi.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
- op: clamp.Tensor_out
7676
kernels:
7777
- arg_meta: null
78-
kernel_name: cadence::impl::HiFi::clamp_tensor_out
78+
kernel_name: cadence::impl::HiFi::clamp_Tensor_out
7979

8080
- op: clone.out
8181
kernels:
@@ -100,7 +100,7 @@
100100
- op: eq.Tensor_out
101101
kernels:
102102
- arg_meta: null
103-
kernel_name: cadence::impl::HiFi::eq_tensor_out
103+
kernel_name: cadence::impl::HiFi::eq_Tensor_out
104104

105105
- op: fmod.Tensor_out
106106
kernels:
@@ -120,12 +120,12 @@
120120
- op: ge.Scalar_out
121121
kernels:
122122
- arg_meta: null
123-
kernel_name: cadence::impl::HiFi::ge_scalar_out
123+
kernel_name: cadence::impl::HiFi::ge_Scalar_out
124124

125125
- op: ge.Tensor_out
126126
kernels:
127127
- arg_meta: null
128-
kernel_name: cadence::impl::HiFi::ge_tensor_out
128+
kernel_name: cadence::impl::HiFi::ge_Tensor_out
129129

130130
- op: gelu.out
131131
kernels:
@@ -135,12 +135,12 @@
135135
- op: gt.Scalar_out
136136
kernels:
137137
- arg_meta: null
138-
kernel_name: cadence::impl::HiFi::gt_scalar_out
138+
kernel_name: cadence::impl::HiFi::gt_Scalar_out
139139

140140
- op: gt.Tensor_out
141141
kernels:
142142
- arg_meta: null
143-
kernel_name: cadence::impl::HiFi::gt_tensor_out
143+
kernel_name: cadence::impl::HiFi::gt_Tensor_out
144144

145145
- op: hardtanh.out
146146
kernels:
@@ -150,27 +150,27 @@
150150
- op: le.Scalar_out
151151
kernels:
152152
- arg_meta: null
153-
kernel_name: cadence::impl::HiFi::le_scalar_out
153+
kernel_name: cadence::impl::HiFi::le_Scalar_out
154154

155155
- op: le.Tensor_out
156156
kernels:
157157
- arg_meta: null
158-
kernel_name: cadence::impl::HiFi::le_tensor_out
158+
kernel_name: cadence::impl::HiFi::le_Tensor_out
159159

160160
- op: lt.Scalar_out
161161
kernels:
162162
- arg_meta: null
163-
kernel_name: cadence::impl::HiFi::lt_scalar_out
163+
kernel_name: cadence::impl::HiFi::lt_Scalar_out
164164

165165
- op: lt.Tensor_out
166166
kernels:
167167
- arg_meta: null
168-
kernel_name: cadence::impl::HiFi::lt_tensor_out
168+
kernel_name: cadence::impl::HiFi::lt_Tensor_out
169169

170170
- op: masked_fill.Scalar_out
171171
kernels:
172172
- arg_meta: null
173-
kernel_name: cadence::impl::HiFi::masked_fill_scalar_out
173+
kernel_name: cadence::impl::HiFi::masked_fill_Scalar_out
174174

175175
- op: max_pool2d_with_indices.out
176176
kernels:
@@ -185,7 +185,7 @@
185185
- op: mean.out
186186
kernels:
187187
- arg_meta: null
188-
kernel_name: cadence::impl::HiFi::mean_out
188+
kernel_name: cadence::impl::HiFi::mean_out
189189

190190
- op: minimum.out
191191
kernels:
@@ -205,7 +205,7 @@
205205
- op: ne.Tensor_out
206206
kernels:
207207
- arg_meta: null
208-
kernel_name: cadence::impl::HiFi::ne_tensor_out
208+
kernel_name: cadence::impl::HiFi::ne_Tensor_out
209209

210210
- op: permute_copy.out
211211
kernels:
@@ -289,11 +289,11 @@
289289
kernels:
290290
- arg_meta: null
291291
kernel_name: cadence::impl::HiFi::dequantize_per_tensor_out
292-
292+
293293
- func: cadence::quantized_conv.out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
294294
kernels:
295295
- arg_meta: null
296-
kernel_name: cadence::impl::HiFi::quantized_conv_out
296+
kernel_name: cadence::impl::HiFi::quantized_conv_out
297297

298298
- func: cadence::quantized_layer_norm.out(Tensor input, Tensor in_scale, Tensor in_zero_point, int[] normalized_shape, Tensor weight, Tensor bias, float eps, float output_scale, int output_zero_point, *, Tensor(a!) out) -> Tensor(a!)
299299
kernels:

backends/cadence/fusion_g3/operators/op_exp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Tensor& exp_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
6060
return out;
6161
} else {
6262
return torch::executor::native::internal::
63-
unary_ufunc_realhbbf16_to_floathbf16(std::exp, ctx, in, out);
63+
unary_ufunc_realhbbf16_to_floathbf16(std::exp, std::exp, ctx, in, out);
6464
}
6565
}
6666

backends/cadence/fusion_g3/operators/op_rsqrt.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace native {
2727

2828
namespace {
2929

30-
double rsqrt(double x) {
30+
template <typename T>
31+
T rsqrt(T x) {
3132
return 1.0 / std::sqrt(x);
3233
}
3334

@@ -61,11 +62,11 @@ Tensor& rsqrt_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
6162
return out;
6263
} else {
6364
return torch::executor::native::internal::
64-
unary_ufunc_realhbbf16_to_floathbf16(rsqrt, ctx, in, out);
65+
unary_ufunc_realhbbf16_to_floathbf16(rsqrt, rsqrt, ctx, in, out);
6566
}
6667
}
6768

6869
} // namespace native
6970
} // namespace G3
7071
} // namespace impl
71-
} // namespace cadence
72+
} // namespace cadence

backends/cadence/fusion_g3/operators/op_sqrt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ Tensor& sqrt_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
5555
return out;
5656
} else {
5757
return torch::executor::native::internal::
58-
unary_ufunc_realhbbf16_to_floathbf16(std::sqrt, ctx, in, out);
58+
unary_ufunc_realhbbf16_to_floathbf16(
59+
std::sqrt, std::sqrt, ctx, in, out);
5960
}
6061
}
6162

backends/cadence/fusion_g3/operators/op_tanh.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ Tensor& tanh_out(KernelRuntimeContext& ctx, const Tensor& in, Tensor& out) {
5555
return out;
5656
} else {
5757
return torch::executor::native::internal::
58-
unary_ufunc_realhbbf16_to_floathbf16(std::tanh, ctx, in, out);
58+
unary_ufunc_realhbbf16_to_floathbf16(
59+
std::tanh, std::tanh, ctx, in, out);
5960
}
6061
}
6162

backends/cadence/hifi/operators/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ target_include_directories(
8888

8989
# Custom ops that are needed to run the test model.
9090
add_library(
91-
custom_ops "op_quantized_linear_out.cpp" "op_quantized_layer_norm.cpp" "quantized_matmul_out.cpp"
91+
custom_ops "op_quantized_linear_out.cpp" "op_quantized_layer_norm.cpp" "op_quantized_matmul_out.cpp"
9292
"op_quantize_per_tensor.cpp" "op_quantized_relu_out.cpp" "op_dequantize_per_tensor.cpp"
9393
"op_quantized_conv_out.cpp" "op_quantized_fully_connected_out"
9494
)

0 commit comments

Comments
 (0)