()
| 188 | |
| 189 | |
| 190 | def test_modify_params(): |
| 191 | |
| 192 | a = Tensor([1, 2]) |
| 193 | b = Tensor([3, 4]) |
| 194 | |
| 195 | @trace(symbolic=True, capture_as_const=True) |
| 196 | def fwd(a, b): |
| 197 | return (a + b) * 2 |
| 198 | |
| 199 | fwd(a, b) |
| 200 | orig_model = io.BytesIO() |
| 201 | fwd.dump( |
| 202 | orig_model, arg_names=["a", "b"], output_names="o", optimize_for_inference=False |
| 203 | ) |
| 204 | orig_model.seek(0) |
| 205 | |
| 206 | graph = Net.load(orig_model) |
| 207 | param_const = graph.params_filter.as_unique() |
| 208 | param_const.set_value(3) |
| 209 | |
| 210 | modified_model = io.BytesIO() |
| 211 | graph.dump(modified_model) |
| 212 | modified_model.seek(0) |
| 213 | load_graph = GraphInference(modified_model) |
| 214 | |
| 215 | out = load_graph.run(a, b) |
| 216 | np.testing.assert_equal(out["o"], [12, 18]) |
| 217 | |
| 218 | |
| 219 | def test_make_const(): |
nothing calls this directly
no test coverage detected