Skip to content
Merged
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: 11 additions & 1 deletion test/legacy_test/test_logit_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def logit_grad(x, eps=1e-8):
)
x_1 = 1.0 - x
_x = np.select([tmp_x == -1.0], [np.reciprocal(x * x_1)], default=0.0)
dout = np.full_like(x, fill_value=1.0 / _x.size)
if _x.size == 0:
dout = np.full_like(x, fill_value=0.0)
else:
dout = np.full_like(x, fill_value=1.0 / _x.size)
dx = dout * _x
return dx

Expand Down Expand Up @@ -151,6 +154,13 @@ def set_attrs(self):
self.eps = 1e-8


class TestLogit_ZeroSize(TestLogitOp):
def set_attrs(self):
self.dtype = np.float64
self.shape = [2, 0]
self.eps = 1e-8


class TestLogitAPI(unittest.TestCase):
def setUp(self):
self.x_shape = [120]
Expand Down