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

Moving to more general tensorized PCs #90

Closed loreloc closed 1 year ago

loreloc commented 1 year ago
  1. Renamed cirkit.models.einet to cirkit.models.pcs.tensorized_pc.
  2. Removed the einet_address from the entire code base:
    • The einet_address was an attribute of region graph nodes that was updated in-place from the previous EiNets implementation. It was replaced by a "throw-away" dictionary that maps region graph node IDs to (i) the corresponding index in the folded tensor and (ii) the layer that computes the folded tensor.
    • The replica_idx attribute of region graph nodes was retained instead, as it is used to fold the input layers. I propose to keep it for now, as it can be a useful attribute for all those region graphs that are "replicated" (e.g., the binary randomized structure in RAT-SPNs), hence requiring "replicated" input layers.
    • The region graph implementations are now completely disentangled with the layer implementations.
  3. Renamed layer classes as to remove any reference to EinsumNetworks:
    • Added package cirkit.layers.factorized that will contains all those layers whose sums and products are "fused", e.g., CP and Tucker2 implementation. The base class for this kind of layers is found in cirkit.layers.factorized.sum_product.

Closes #73 .

arranger1044 commented 1 year ago

Some comments on nomenclature:

loreloc commented 1 year ago

Some comments on nomenclature:

* do we really need `pc` in `cirkit.models.pcs.tensorized_pc`? I'd go with `cirkit.models.tensorized_circuit` as we do not need to stick to PCs now and one more layer in the hierarchy does not feel useful to disambiguate among what we will have

* `factorized` feels a bit ambiguous. Why not having directly `sum_product` after `layers`?
arranger1044 commented 1 year ago

we could specialize it later, if needed