Open lkct opened 1 year ago
cc @loreloc Continuing the discussion in the previous PR, I have another option of mixin classes. Maybe it's better? (in the sense that we can add multiple utils with one mixin)
I think it's better to have simple utility functions for now.
It seems we can always switch to mixin classes easily, if we notice we need many utility functions like num_params
.
Ref https://github.com/april-tools/cirkit/pull/110#discussion_r1259570153.
We can add some utils for some commonly used properties/methods on layers and models (which subclass
Module
).num_params
for the number of trainable params in the module (and a flag to exclude the params set torequires_grad=False
)One option is to use util functions as in the discussion ref above. Another option is to use mixin classes (mypy's guide on how to type them: https://mypy.readthedocs.io/en/stable/more_types.html#mixin-classes)