Skip to content

Commit 38f2dfc

Browse files
Use property setters for parameters and buffers when available.
1 parent ad7ad4e commit 38f2dfc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/TorchSharp/NN/Module.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,10 @@ protected virtual void _toEpilog(ScalarType? dtype, Device? device, bool non_blo
254254
var props = GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
255255

256256
var propsByName = new Dictionary<string, PropertyInfo>();
257-
// foreach (var p in props) {
258-
// // There may be duplicates, and this just overwrites it.
259-
// //propsByName.Add(p.Name, p);
260-
// propsByName[p.Name] = p;
261-
// }
257+
foreach (var p in props) {
258+
// There may be duplicates, and this just overwrites it.
259+
propsByName[p.Name] = p;
260+
}
262261

263262
foreach (var (name, param) in named_parameters(false).ToList()) {
264263
using var grad = param.grad;

0 commit comments

Comments
 (0)