fix mean underflow for half tensor (#4377)

* fix mean underflow for half tensor

divide only the reduce factor. added unit test and non-nan assertion in resnet training. also added a failed test cast for symbolic shape var

* skip for python backend
This commit is contained in:
chenyu
2024-05-01 13:38:57 -04:00
committed by GitHub
parent dce7ac0160
commit 826cccd54d
4 changed files with 19 additions and 2 deletions

View File

@@ -32,6 +32,14 @@ class TestTensorVariable(unittest.TestCase):
ret = t.mean().item()
assert ret == 1
@unittest.skip("symbolic var isn't supported")
def test_symbolic_var(self):
vv = Variable("a", 1, 10)
vv.bind(2)
t = Tensor.ones(2, 2).contiguous().reshape(2, vv)
ret = t.var().item()
assert ret == 0
def test_symbolic_mean_2d(self):
vv = Variable("a", 1, 10)
vv.bind(2)