()
| 86 | |
| 87 | |
| 88 | def 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 | |
| 110 | def test_mse_loss_append(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…