Skip to content

Commit 6609da9

Browse files
zonglinpengfacebook-github-bot
authored andcommitted
port hardtanh and add hardtanh test
Summary: titled Differential Revision: D72405686
1 parent c70c208 commit 6609da9

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

backends/cadence/fusion_g3/operators/targets.bzl

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ OPERATORS = [
4040
"rsqrt",
4141
"sigmoid",
4242
"sqrt",
43+
"hardtanh",
4344
"tanh",
4445
"transpose_copy",
4546
"where",

backends/cadence/utils/facto_util.py

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def apply_scalar_contraints(op_name: str) -> list[ScalarDtype]:
9999
match op_name:
100100
case "add.Scalar" | "sub.Scalar" | "mul.Scalar" | "div.Scalar":
101101
return [ScalarDtype.int]
102+
102103
case _:
103104
return [ScalarDtype.float, ScalarDtype.int]
104105

@@ -122,6 +123,11 @@ def facto_testcase_gen(op_name: str) -> List[Tuple[List[str], OrderedDict[str, s
122123
cp.Size.Le(lambda deps, r, d: 2**2),
123124
]
124125
)
126+
if in_spec.name == "max_val": # hardtanh
127+
spec.inspec[index].deps = [0, 1]
128+
spec.inspec[index].constraints.extend(
129+
[cp.Value.Ge(lambda deps, _: deps[1])]
130+
)
125131
else:
126132
spec.inspec[index].constraints.extend(
127133
[

0 commit comments

Comments
 (0)