april-tools / cirkit

a python framework to build, learn and reason about probabilistic circuits and tensor networks
https://cirkit-docs.readthedocs.io/en/latest/
GNU General Public License v3.0
71 stars 1 forks source link

Utils mixin for `Module` (sub)classes (num params etc.) #111

Open lkct opened 1 year ago

lkct commented 1 year ago

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).

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)

lkct commented 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)

loreloc commented 1 year ago

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.