Skip to content

Commit a1a4897

Browse files
committed
[Relay] avoid using relay module
1 parent fe4bf19 commit a1a4897

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

python/tvm/relay/op/_tensor_grad.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from .transform import collapse_sum_like, broadcast_to_like, where
2323
from .tensor import exp, negative, power, less
2424
from .tensor import zeros_like, ones_like
25-
from tvm import relay
2625

2726
@register_gradient("log")
2827
def log_grad(orig, grad):
@@ -124,11 +123,9 @@ def clip_grad(orig, grad):
124123
"""Returns grad * (select(x < min || max < x , 0, 1))."""
125124
x = orig.args[0]
126125
a_min = orig.attrs.get_int("a_min")
127-
a_min_const = relay.const(a_min)
128126
a_max = orig.attrs.get_int("a_max")
129-
a_max_const = relay.const(a_max)
130-
a_mins = relay.full_like(x, a_min_const)
131-
a_maxs = relay.full_like(x, a_max_const)
127+
a_mins = broadcast_to_like(const(a_min), x)
128+
a_maxs = broadcast_to_like(const(a_max), x)
132129
zeros = zeros_like(x)
133130
ones = ones_like(x)
134131
return [where(less(x, a_mins), zeros, where(less(a_maxs, x), zeros, ones * grad))]

0 commit comments

Comments
 (0)