MCPcopy Create free account
hub / github.com/apache/tvm / test_mse_loss

Function test_mse_loss

tests/python/relax/test_training_loss.py:88–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86
87
88def test_mse_loss():
89 N = 3
90 C = 5
91 predictions = relax.TensorStructInfo((N, C), "float32")
92 targets = relax.TensorStructInfo((N, C), "float32")
93 mse_loss = relax.training.loss.MSELoss()
94
95 @R.function
96 def expected(
97 predictions: R.Tensor((3, 5), "float32"), targets: R.Tensor((3, 5), "float32")
98 ) -> R.Tensor((), "float32"):
99 R.func_attr({"global_symbol": "mse_loss"})
100 with R.dataflow():
101 lv: R.Tensor((3, 5), "float32") = R.subtract(predictions, targets)
102 lv1: R.Tensor((3, 5), "float32") = R.multiply(lv, lv)
103 gv: R.Tensor((), "float32") = R.mean(lv1, axis=None, keepdims=False)
104 R.output(gv)
105 return gv
106
107 assert_structural_equal(mse_loss(predictions, targets), expected)
108
109
110def test_mse_loss_append():

Callers

nothing calls this directly

Calls 1

assert_structural_equalFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…