compiled-knowledge 4.0.0a10__cp312-cp312-win_amd64.whl → 4.0.0a11__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of compiled-knowledge might be problematic. Click here for more details.
- ck/circuit/circuit.cp312-win_amd64.pyd +0 -0
- ck/circuit/circuit.pyx +11 -5
- ck/circuit/circuit_py.py +40 -19
- ck/circuit_compiler/cython_vm_compiler/_compiler.cp312-win_amd64.pyd +0 -0
- ck/pgm.py +33 -93
- ck/pgm_compiler/support/circuit_table/circuit_table.cp312-win_amd64.pyd +0 -0
- ck/program/program.py +9 -1
- ck/program/raw_program.py +9 -3
- {compiled_knowledge-4.0.0a10.dist-info → compiled_knowledge-4.0.0a11.dist-info}/METADATA +16 -12
- {compiled_knowledge-4.0.0a10.dist-info → compiled_knowledge-4.0.0a11.dist-info}/RECORD +13 -16
- ck/circuit/circuit.c +0 -38860
- ck/circuit_compiler/cython_vm_compiler/_compiler.c +0 -17373
- ck/pgm_compiler/support/circuit_table/circuit_table.c +0 -16042
- {compiled_knowledge-4.0.0a10.dist-info → compiled_knowledge-4.0.0a11.dist-info}/WHEEL +0 -0
- {compiled_knowledge-4.0.0a10.dist-info → compiled_knowledge-4.0.0a11.dist-info}/licenses/LICENSE.txt +0 -0
- {compiled_knowledge-4.0.0a10.dist-info → compiled_knowledge-4.0.0a11.dist-info}/top_level.txt +0 -0
|
Binary file
|
ck/circuit/circuit.pyx
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"""
|
|
2
|
+
For more documentation on this module, refer to the Jupyter notebook docs/6_circuits_and_programs.ipynb.
|
|
3
|
+
"""
|
|
1
4
|
from __future__ import annotations
|
|
2
5
|
|
|
3
6
|
from itertools import chain
|
|
@@ -15,12 +18,15 @@ MUL: int = 1
|
|
|
15
18
|
|
|
16
19
|
cdef class Circuit:
|
|
17
20
|
"""
|
|
18
|
-
An arithmetic circuit
|
|
19
|
-
and constant values (ConstNode objects). Computation is defined
|
|
20
|
-
ring, with two operations: addition
|
|
21
|
+
An arithmetic circuit defines an arithmetic function from input variables (`VarNode` objects)
|
|
22
|
+
and constant values (`ConstNode` objects) to one or more result values. Computation is defined
|
|
23
|
+
over a mathematical ring, with two operations: addition and multiplication (represented
|
|
24
|
+
by `OpNode` objects).
|
|
21
25
|
|
|
22
|
-
An arithmetic circuit
|
|
23
|
-
|
|
26
|
+
An arithmetic circuit needs to be compiled to a program to execute the function.
|
|
27
|
+
|
|
28
|
+
All nodes belong to a circuit. All nodes are immutable, with the exception that a
|
|
29
|
+
`VarNode` may be temporarily be set to a constant value.
|
|
24
30
|
"""
|
|
25
31
|
|
|
26
32
|
cdef public list[VarNode] vars
|
ck/circuit/circuit_py.py
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This is a pure Python implementation of Circuits (for testing and development)
|
|
3
|
+
|
|
4
|
+
For more documentation on this module, refer to the Jupyter notebook docs/6_circuits_and_programs.ipynb.
|
|
5
|
+
"""
|
|
6
|
+
|
|
1
7
|
from __future__ import annotations
|
|
2
8
|
|
|
3
9
|
from dataclasses import dataclass, field
|
|
@@ -14,12 +20,15 @@ MUL: int = 1
|
|
|
14
20
|
|
|
15
21
|
class Circuit:
|
|
16
22
|
"""
|
|
17
|
-
An arithmetic circuit
|
|
18
|
-
and constant values (ConstNode objects). Computation is defined
|
|
19
|
-
ring, with two operations: addition
|
|
23
|
+
An arithmetic circuit defines an arithmetic function from input variables (`VarNode` objects)
|
|
24
|
+
and constant values (`ConstNode` objects) to one or more result values. Computation is defined
|
|
25
|
+
over a mathematical ring, with two operations: addition and multiplication (represented
|
|
26
|
+
by `OpNode` objects).
|
|
20
27
|
|
|
21
|
-
An arithmetic circuit
|
|
22
|
-
|
|
28
|
+
An arithmetic circuit needs to be compiled to a program to execute the function.
|
|
29
|
+
|
|
30
|
+
All nodes belong to a circuit. All nodes are immutable, with the exception that a
|
|
31
|
+
`VarNode` may be temporarily be set to a constant value.
|
|
23
32
|
"""
|
|
24
33
|
|
|
25
34
|
def __init__(self, zero: ConstValue = 0, one: ConstValue = 1):
|
|
@@ -352,6 +361,7 @@ class Circuit:
|
|
|
352
361
|
prefix: str = '',
|
|
353
362
|
indent: str = ' ',
|
|
354
363
|
var_names: Optional[List[str]] = None,
|
|
364
|
+
include_consts: bool = False,
|
|
355
365
|
) -> None:
|
|
356
366
|
"""
|
|
357
367
|
Print a dump of the Circuit.
|
|
@@ -361,6 +371,7 @@ class Circuit:
|
|
|
361
371
|
prefix: optional prefix for indenting all lines.
|
|
362
372
|
indent: additional prefix to use for extra indentation.
|
|
363
373
|
var_names: optional variable names to show.
|
|
374
|
+
include_consts: if true, then constant values are dumped.
|
|
364
375
|
"""
|
|
365
376
|
|
|
366
377
|
next_prefix: str = prefix + indent
|
|
@@ -374,34 +385,38 @@ class Circuit:
|
|
|
374
385
|
print(f'{prefix}number of arcs: {self.number_of_arcs:,}')
|
|
375
386
|
|
|
376
387
|
print(f'{prefix}var nodes: {self.number_of_vars}')
|
|
377
|
-
for var in self.
|
|
388
|
+
for var in self.vars:
|
|
378
389
|
node_name[id(var)] = f'var[{var.idx}]'
|
|
379
390
|
var_name: str = '' if var_names is None or var.idx >= len(var_names) else var_names[var.idx]
|
|
380
391
|
if var_name != '':
|
|
381
392
|
if var.is_const():
|
|
382
|
-
print(f'{next_prefix}var[{var.idx}]: {var_name},
|
|
393
|
+
print(f'{next_prefix}var[{var.idx}]: {var_name}, {var.const.value}')
|
|
383
394
|
else:
|
|
384
395
|
print(f'{next_prefix}var[{var.idx}]: {var_name}')
|
|
385
396
|
elif var.is_const():
|
|
386
|
-
print(f'{next_prefix}var[{var.idx}]:
|
|
397
|
+
print(f'{next_prefix}var[{var.idx}]: {var.const.value}')
|
|
398
|
+
|
|
399
|
+
if include_consts:
|
|
400
|
+
print(f'{prefix}const nodes: {self.number_of_consts}')
|
|
401
|
+
for const in self._const_map.values():
|
|
402
|
+
print(f'{next_prefix}{const.value!r}')
|
|
387
403
|
|
|
388
|
-
|
|
404
|
+
# Add const nodes to the node_name dict
|
|
389
405
|
for const in self._const_map.values():
|
|
390
|
-
node_name[id(const)] =
|
|
391
|
-
print(f'{next_prefix}const({const.value})')
|
|
406
|
+
node_name[id(const)] = repr(const.value)
|
|
392
407
|
|
|
393
408
|
# Add op nodes to the node_name dict
|
|
394
|
-
for i, op in enumerate(self.
|
|
395
|
-
node_name[id(op)] = f'{op.
|
|
409
|
+
for i, op in enumerate(self.ops):
|
|
410
|
+
node_name[id(op)] = f'{op.op_str()}<{i}>'
|
|
396
411
|
|
|
397
412
|
print(
|
|
398
413
|
f'{prefix}op nodes: {self.number_of_op_nodes} '
|
|
399
414
|
f'(arcs: {self.number_of_arcs}, ops: {self.number_of_operations})'
|
|
400
415
|
)
|
|
401
|
-
for op in reversed(self.
|
|
416
|
+
for op in reversed(self.ops):
|
|
402
417
|
op_name = node_name[id(op)]
|
|
403
418
|
args_str = ' '.join(node_name[id(arg)] for arg in op.args)
|
|
404
|
-
print(f'{next_prefix}{op_name}
|
|
419
|
+
print(f'{next_prefix}{op_name}: {args_str}')
|
|
405
420
|
|
|
406
421
|
def _check_nodes(self, nodes: Iterable[Args]) -> Tuple[CircuitNode, ...]:
|
|
407
422
|
"""
|
|
@@ -585,12 +600,18 @@ class OpNode(CircuitNode):
|
|
|
585
600
|
self.symbol: int = symbol
|
|
586
601
|
|
|
587
602
|
def __str__(self) -> str:
|
|
603
|
+
return f'{self.op_str()}\\{len(self.args)}'
|
|
604
|
+
|
|
605
|
+
def op_str(self) -> str:
|
|
606
|
+
"""
|
|
607
|
+
Returns the op node operation as a string.
|
|
608
|
+
"""
|
|
588
609
|
if self.symbol == MUL:
|
|
589
|
-
return
|
|
610
|
+
return 'mul'
|
|
590
611
|
elif self.symbol == ADD:
|
|
591
|
-
return
|
|
612
|
+
return 'add'
|
|
592
613
|
else:
|
|
593
|
-
return
|
|
614
|
+
return '?' + str(self.symbol)
|
|
594
615
|
|
|
595
616
|
|
|
596
617
|
@dataclass
|
|
@@ -688,7 +709,7 @@ class _DerivativeHelper:
|
|
|
688
709
|
for value in (self._derivative_prod(prods) for prods in d_node.sum_prod)
|
|
689
710
|
if not value.is_zero()
|
|
690
711
|
)
|
|
691
|
-
#
|
|
712
|
+
# We can release the temporary memory at this DNode now
|
|
692
713
|
d_node.sum_prod = None
|
|
693
714
|
|
|
694
715
|
# Construct the addition operation
|
|
Binary file
|
ck/pgm.py
CHANGED
|
@@ -1,80 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
A probabilistic graphical model (PGM) represents a joint probability distribution over
|
|
5
|
-
a set of random variables. Specifically, a PGM is a factor graph with discrete random variables.
|
|
6
|
-
|
|
7
|
-
A random variable is represented by a RandomVariable object. Each random variable has a
|
|
8
|
-
fixed, finite number of states. Many algorithms will assume at least two states.
|
|
9
|
-
Every RandomVariable object belongs to exactly one PGM object. A RandomVariable
|
|
10
|
-
has a name (for human convenience) and its states are indexed by integers, counting
|
|
11
|
-
from zero.
|
|
12
|
-
|
|
13
|
-
A PGM also has factors. Each Factor of a PGM connects a set of RandomVariable objects
|
|
14
|
-
of the PGM. In general, the order of the random variables of a factor is functionally
|
|
15
|
-
irrelevant, but is practically relevant for operating with Factor objects. The "shape"
|
|
16
|
-
of a factor is the list of the numbers of states of the factor's random variables (co-indexed
|
|
17
|
-
with the list of random variables of the factor).
|
|
18
|
-
|
|
19
|
-
If a PGM is representing a Bayesian network, then each factor represents a conditional
|
|
20
|
-
probability table (CPT) and the first random variable of the factor is taken to be the child
|
|
21
|
-
random variable, with the remaining random variables being the parents.
|
|
22
|
-
|
|
23
|
-
Every factor has associated with it a potential function. A potential function maps
|
|
24
|
-
each combination of states of the factor's random variables to a value (of type float).
|
|
25
|
-
A combination of states of random variables is represented as a Key. A Key is essentially
|
|
26
|
-
a list of state indexes, co-indexed with the factor's random variables.
|
|
27
|
-
|
|
28
|
-
A potential function is a map from all possible keys (according to the potential function's
|
|
29
|
-
shape) to a float value. Each potential function has zero or more "parameters" which may be
|
|
30
|
-
adjusted to change the potential function's mapping. The parameters of a potential function
|
|
31
|
-
are indexed sequentially from zero.
|
|
32
|
-
|
|
33
|
-
Each parameter of a potential function is associated with one or more keys. The value of the
|
|
34
|
-
parameter is the value of the potential function for it's associated keys. Conversely, each
|
|
35
|
-
key of a potential function is associate with zero or one parameters. That is, it is possible
|
|
36
|
-
that a potential function maps multiple keys to the same parameter, in which case keys that map
|
|
37
|
-
to the same parameter will have the same value.
|
|
38
|
-
|
|
39
|
-
If a key of a potential function is associated with a parameter, then the value of
|
|
40
|
-
the potential function for that key is the value of the parameter.
|
|
41
|
-
|
|
42
|
-
If a key of a potential function is associated with zero parameters then the value of
|
|
43
|
-
the potential function for that key is zero. Furthermore, the key is referred to as
|
|
44
|
-
"guaranteed-zero", meaning that no change in the parameter values of the potential function
|
|
45
|
-
will change the value for that key away from zero.
|
|
46
|
-
|
|
47
|
-
RandomVariable objects are immutable and hashable, including their states.
|
|
48
|
-
|
|
49
|
-
Factor objects cannot change the random variables they are a factor of. However,
|
|
50
|
-
the PotentialFunction associated with a Factor may be updated.
|
|
51
|
-
|
|
52
|
-
Factors may share a potential function, so long as they have the same shape.
|
|
53
|
-
|
|
54
|
-
PotentialFunction objects cannot change their shape, but may be otherwise mutable and
|
|
55
|
-
are generally not hashable. A particular class of potential function may allow its mapping
|
|
56
|
-
to change and even its available parameters to change.
|
|
57
|
-
|
|
58
|
-
There are many kinds of potential function. A DensePotentialFunction has exactly
|
|
59
|
-
one parameter for each possible key (no 'guaranteed-zero' keys) and there are no
|
|
60
|
-
shared parameters. A SparsePotentialFunction only has parameters for explicitly
|
|
61
|
-
mentioned keys.
|
|
62
|
-
|
|
63
|
-
There is a special class of potential function called a ZeroPotentialFunction which
|
|
64
|
-
(like DensePotentialFunction) has a parameter for each possible key (and thus no
|
|
65
|
-
key is guaranteed-zero). However, the value of each parameter is zero and there
|
|
66
|
-
is no mechanism to update these values.
|
|
67
|
-
|
|
68
|
-
A ZeroPotentialFunction is the default PotentialFunction for a Factor. It may be seen
|
|
69
|
-
as a light-weight placeholder until replaced by some other potential function.
|
|
70
|
-
It may also be used as a light-weight surrogate for a DensePotentialFunction when
|
|
71
|
-
performing PGM parameter learning.
|
|
72
|
-
|
|
73
|
-
Each RandomVariable has an index (`idx`) which is a sequence number, starting from zero,
|
|
74
|
-
indicating when that RandomVariable was added to its PGM.
|
|
75
|
-
|
|
76
|
-
Each Factor has an index (`idx`) which is a sequence number, starting from zero,
|
|
77
|
-
indicating when that Factor was added to its PGM.
|
|
2
|
+
For more documentation on this module, refer to the Jupyter notebook docs/4_PGM_advanced.ipynb.
|
|
78
3
|
"""
|
|
79
4
|
from __future__ import annotations
|
|
80
5
|
|
|
@@ -2148,6 +2073,8 @@ class DensePotentialFunction(PotentialFunction):
|
|
|
2148
2073
|
|
|
2149
2074
|
@property
|
|
2150
2075
|
def params(self) -> Iterable[Tuple[int, float]]:
|
|
2076
|
+
# Type warning due to numpy type erasure
|
|
2077
|
+
# noinspection PyTypeChecker
|
|
2151
2078
|
return enumerate(self._values)
|
|
2152
2079
|
|
|
2153
2080
|
@property
|
|
@@ -2324,9 +2251,12 @@ class DensePotentialFunction(PotentialFunction):
|
|
|
2324
2251
|
class SparsePotentialFunction(PotentialFunction):
|
|
2325
2252
|
"""
|
|
2326
2253
|
A sparse potential function.
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2254
|
+
|
|
2255
|
+
There is one parameter for each non-zero key value.
|
|
2256
|
+
The user may set the value for any key and parameters will
|
|
2257
|
+
be automatically reconfigured as needed. Setting the value for
|
|
2258
|
+
a key to zero disassociates the key from its parameter and
|
|
2259
|
+
thus makes that key "guaranteed zero".
|
|
2330
2260
|
"""
|
|
2331
2261
|
|
|
2332
2262
|
def __init__(self, factor: Factor):
|
|
@@ -2381,7 +2311,7 @@ class SparsePotentialFunction(PotentialFunction):
|
|
|
2381
2311
|
"""
|
|
2382
2312
|
Set the potential function value, for a given key.
|
|
2383
2313
|
|
|
2384
|
-
|
|
2314
|
+
If value is zero, then the key will become "guaranteed zero".
|
|
2385
2315
|
|
|
2386
2316
|
Arg:
|
|
2387
2317
|
key: defines an instance in the state space of the potential function.
|
|
@@ -2395,7 +2325,7 @@ class SparsePotentialFunction(PotentialFunction):
|
|
|
2395
2325
|
|
|
2396
2326
|
if param_idx is None:
|
|
2397
2327
|
if value == 0:
|
|
2398
|
-
#
|
|
2328
|
+
# Nothing to do
|
|
2399
2329
|
return
|
|
2400
2330
|
param_idx = len(self._values)
|
|
2401
2331
|
self._values.append(value)
|
|
@@ -2403,11 +2333,16 @@ class SparsePotentialFunction(PotentialFunction):
|
|
|
2403
2333
|
return
|
|
2404
2334
|
|
|
2405
2335
|
if value != 0:
|
|
2406
|
-
#
|
|
2336
|
+
# Simple case
|
|
2407
2337
|
self._values[param_idx] = value
|
|
2408
2338
|
return
|
|
2409
2339
|
|
|
2410
|
-
#
|
|
2340
|
+
# This is the case where the key was associated with a parameter
|
|
2341
|
+
# but the value is being set to zero, so we
|
|
2342
|
+
# need to clear an existing non-zero parameter.
|
|
2343
|
+
# This code operates by first ensuring the parameter is the last one,
|
|
2344
|
+
# then popping the last parameter.
|
|
2345
|
+
|
|
2411
2346
|
end: int = len(self._values) - 1
|
|
2412
2347
|
if param_idx != end:
|
|
2413
2348
|
# need to swap the parameter with the end.
|
|
@@ -2419,7 +2354,7 @@ class SparsePotentialFunction(PotentialFunction):
|
|
|
2419
2354
|
# There will only be one, so we can break now
|
|
2420
2355
|
break
|
|
2421
2356
|
|
|
2422
|
-
#
|
|
2357
|
+
# Remove the parameter
|
|
2423
2358
|
self._values.pop()
|
|
2424
2359
|
self._params.pop(instance)
|
|
2425
2360
|
|
|
@@ -2568,10 +2503,14 @@ class SparsePotentialFunction(PotentialFunction):
|
|
|
2568
2503
|
|
|
2569
2504
|
class CompactPotentialFunction(PotentialFunction):
|
|
2570
2505
|
"""
|
|
2571
|
-
A
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2506
|
+
A compact potential function is sparse, where values for keys of
|
|
2507
|
+
the same value are represented by a single parameter.
|
|
2508
|
+
|
|
2509
|
+
There is one parameter for each unique, non-zero key value.
|
|
2510
|
+
The user may set the value for any key and parameters will
|
|
2511
|
+
be automatically reconfigured as needed. Setting the value for
|
|
2512
|
+
a key to zero disassociates the key from its parameter and
|
|
2513
|
+
thus makes that key "guaranteed zero".
|
|
2575
2514
|
"""
|
|
2576
2515
|
|
|
2577
2516
|
def __init__(self, factor: Factor):
|
|
@@ -2799,9 +2738,9 @@ class CompactPotentialFunction(PotentialFunction):
|
|
|
2799
2738
|
|
|
2800
2739
|
def _remove_param(self, param_idx: int) -> None:
|
|
2801
2740
|
"""
|
|
2802
|
-
Remove the
|
|
2741
|
+
Remove the indexed parameter from self._params and self._counts.
|
|
2803
2742
|
If the parameter is not at the end of the list of parameters
|
|
2804
|
-
then it will be swapped with the
|
|
2743
|
+
then it will be swapped with the last parameter in the list.
|
|
2805
2744
|
"""
|
|
2806
2745
|
|
|
2807
2746
|
# ensure the parameter is at the end of the list
|
|
@@ -2823,10 +2762,10 @@ class CompactPotentialFunction(PotentialFunction):
|
|
|
2823
2762
|
|
|
2824
2763
|
class ClausePotentialFunction(PotentialFunction):
|
|
2825
2764
|
"""
|
|
2826
|
-
A clause potential function represents a clause
|
|
2827
|
-
|
|
2765
|
+
A clause potential function represents a clause From a CNF formula.
|
|
2766
|
+
I.e. a clause over variables X, Y, Z, is a disjunction of the form: 'X=x or Y=y or Z=z'.
|
|
2828
2767
|
|
|
2829
|
-
A clause potential function guaranteed zero for
|
|
2768
|
+
A clause potential function is guaranteed zero for a key where the clause is false,
|
|
2830
2769
|
i.e., when 'X != x and Y != y and Z != z'.
|
|
2831
2770
|
|
|
2832
2771
|
For keys where the clause is true, the value of the potential function
|
|
@@ -3527,6 +3466,7 @@ _CLEAN_CHARS: Set[str] = set('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX
|
|
|
3527
3466
|
def _clean_str(s) -> str:
|
|
3528
3467
|
"""
|
|
3529
3468
|
Quote a string if empty or not all characters are in _CLEAN_CHARS.
|
|
3469
|
+
This is used when rendering indicators.
|
|
3530
3470
|
"""
|
|
3531
3471
|
s = str(s)
|
|
3532
3472
|
if len(s) == 0 or not all(c in _CLEAN_CHARS for c in s):
|
|
Binary file
|
ck/program/program.py
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"""
|
|
2
|
+
For more documentation on this module, refer to the Jupyter notebook docs/6_circuits_and_programs.ipynb.
|
|
3
|
+
"""
|
|
1
4
|
from typing import Callable, Sequence
|
|
2
5
|
|
|
3
6
|
import numpy as np
|
|
@@ -8,7 +11,12 @@ from ck.utils.np_extras import DTypeNumeric, NDArrayNumeric
|
|
|
8
11
|
|
|
9
12
|
class Program:
|
|
10
13
|
"""
|
|
11
|
-
A
|
|
14
|
+
A program represents an arithmetic a function from input values to output values.
|
|
15
|
+
|
|
16
|
+
Internally a `Program` wraps a `RawProgram` which is the object returned by a circuit compiler.
|
|
17
|
+
|
|
18
|
+
Every `Program` has a numpy `dtype` which defines the numeric data type for input and output values.
|
|
19
|
+
Typically, the `dtype` of a program is a C style double.
|
|
12
20
|
"""
|
|
13
21
|
|
|
14
22
|
def __init__(self, raw_program: RawProgram):
|
ck/program/raw_program.py
CHANGED
|
@@ -9,8 +9,8 @@ from ck.utils.np_extras import NDArrayNumeric, DTypeNumeric
|
|
|
9
9
|
|
|
10
10
|
# RawProgramFunction is a function of three ctypes arrays, returning nothing.
|
|
11
11
|
# Args:
|
|
12
|
-
# [0]: input
|
|
13
|
-
# [1]: working memory,
|
|
12
|
+
# [0]: input values,
|
|
13
|
+
# [1]: temporary working memory,
|
|
14
14
|
# [2]: output values.
|
|
15
15
|
RawProgramFunction = Callable[[ct.POINTER, ct.POINTER, ct.POINTER], None]
|
|
16
16
|
|
|
@@ -18,10 +18,16 @@ RawProgramFunction = Callable[[ct.POINTER, ct.POINTER, ct.POINTER], None]
|
|
|
18
18
|
@dataclass
|
|
19
19
|
class RawProgram:
|
|
20
20
|
"""
|
|
21
|
+
A raw program is returned by a circuit compiler to provide execution of
|
|
22
|
+
the function defined by a compiled circuit.
|
|
23
|
+
|
|
24
|
+
A `RawProgram` is a `Callable` with the signature:
|
|
25
|
+
|
|
26
|
+
|
|
21
27
|
Fields:
|
|
22
28
|
function: is a function of three ctypes arrays, returning nothing.
|
|
23
29
|
dtype: the numpy data type of the array values.
|
|
24
|
-
number_of_vars: the number of input
|
|
30
|
+
number_of_vars: the number of input values (first function argument).
|
|
25
31
|
number_of_tmps: the number of working memory values (second function argument).
|
|
26
32
|
number_of_results: the number of result values (third function argument).
|
|
27
33
|
var_indices: maps the index of inputs (from 0 to self.number_of_vars - 1) to the index
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: compiled-knowledge
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.0a11
|
|
4
4
|
Summary: A Python package for compiling and querying discrete probabilistic graphical models.
|
|
5
5
|
Author-email: Barry Drake <barry@compiledknowledge.org>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -15,17 +15,17 @@ Requires-Dist: llvmlite
|
|
|
15
15
|
Requires-Dist: numpy
|
|
16
16
|
Dynamic: license-file
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
Compiled Knowledge
|
|
19
|
+
==================
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
The aim of this repository is:
|
|
21
|
+
Compiled Knowledge is a Python package for compiling and querying discrete probabilistic graphical models.
|
|
22
|
+
The aim of the project is:
|
|
24
23
|
- to provide a Python library for compiling and querying
|
|
25
|
-
probabilistic graphical models, specifically discrete factor graphs
|
|
24
|
+
probabilistic graphical models, specifically discrete factor graphs,
|
|
25
|
+
which includes Bayesian networks
|
|
26
26
|
- to be extremely efficient, flexible, and easy to use
|
|
27
27
|
- to exhibit excellent design, code, and documentation
|
|
28
|
-
- support researchers and businesses wanting to explore and use
|
|
28
|
+
- to support researchers and businesses wanting to explore and use
|
|
29
29
|
probabilistic artificial intelligence.
|
|
30
30
|
|
|
31
31
|
License
|
|
@@ -37,10 +37,14 @@ MIT license (see the file `LICENSE.txt`).
|
|
|
37
37
|
More Information
|
|
38
38
|
================
|
|
39
39
|
|
|
40
|
-
Refer to the project
|
|
40
|
+
Refer to the project online documentation at
|
|
41
|
+
[compiled-knowledge.readthedocs.io](https://compiled-knowledge.readthedocs.io/).
|
|
41
42
|
|
|
42
|
-
The primary
|
|
43
|
+
The primary repository for the project is
|
|
44
|
+
[github.com/ropeless/compiled_knowledge](https://github.com/ropeless/compiled_knowledge).
|
|
43
45
|
|
|
44
|
-
The Python package is available on
|
|
46
|
+
The Python package is available on PyPi, see
|
|
47
|
+
[pypi.org/project/compiled-knowledge](https://pypi.org/project/compiled-knowledge/).
|
|
45
48
|
|
|
46
|
-
For more information email
|
|
49
|
+
For more information email
|
|
50
|
+
[info@compiledknowledge.org](mailto:info@compiledknowledge.org).
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
ck/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
ck/pgm.py,sha256=
|
|
2
|
+
ck/pgm.py,sha256=rbqgP-clfSvgpzUXxVjk_6SdM9neHmpChku6qpyeidk,120700
|
|
3
3
|
ck/circuit/__init__.py,sha256=tozFNNVzsgQDwFrtGzrgcFS4XTszhgyFmbMGfV5pimc,212
|
|
4
|
-
ck/circuit/circuit.
|
|
5
|
-
ck/circuit/circuit.
|
|
6
|
-
ck/circuit/circuit.pyx,sha256=H5OIVZS7Ft5K3b-1KPna815JHfwhvoQPQBcvJq3IZCY,27854
|
|
4
|
+
ck/circuit/circuit.cp312-win_amd64.pyd,sha256=InSRSXXMYNc_7RyWOZx_EeRDwboCCyMPLhd8O1vslJ4,252416
|
|
5
|
+
ck/circuit/circuit.pyx,sha256=Y35CZMalySX8_uhNH6wIaZzS6ACn3rh3L99bog1lQx8,28060
|
|
7
6
|
ck/circuit/circuit_node.pyx,sha256=8RuEC1ngYxnsGryzQ1lOEPc4ewTxvKwc56sOxWLB9zs,4103
|
|
8
|
-
ck/circuit/circuit_py.py,sha256=
|
|
7
|
+
ck/circuit/circuit_py.py,sha256=_k8H1yZsfp2vERkX_CIo8VxxOf1ICw2zL8i2ckoaSlE,28127
|
|
9
8
|
ck/circuit/tmp_const.py,sha256=dG9FuGfoAG5qjYG1rNwekqKiea_KmVfxHMTOgCPbBiQ,2372
|
|
10
9
|
ck/circuit_compiler/__init__.py,sha256=T0Igyp5jPgnIXv4oRcIYhmsOdcNOb3L4Za6dK6eYk7g,132
|
|
11
10
|
ck/circuit_compiler/circuit_compiler.py,sha256=8BLB8DUnPbpl5PXZsIopydPbItytdn2rzRfM2U1EC84,1018
|
|
@@ -14,8 +13,7 @@ ck/circuit_compiler/llvm_compiler.py,sha256=ejeNPkO5Og2FyjjyA5JAexxUl1f8IJ6mwU5N
|
|
|
14
13
|
ck/circuit_compiler/llvm_vm_compiler.py,sha256=I46_XV5FrClDKO06zIjn8T3ME5XQ9RYJ_1aAE8e_YzM,21873
|
|
15
14
|
ck/circuit_compiler/named_circuit_compilers.py,sha256=Fsk2HANYhw25uxAdOo5-7aSnVZxlPgsaPz9wO_1YdRg,2400
|
|
16
15
|
ck/circuit_compiler/cython_vm_compiler/__init__.py,sha256=pEAwTleuZgdYhTAQMea2f9YsFK54eoNbZSbrWkW8aeE,49
|
|
17
|
-
ck/circuit_compiler/cython_vm_compiler/_compiler.
|
|
18
|
-
ck/circuit_compiler/cython_vm_compiler/_compiler.cp312-win_amd64.pyd,sha256=S3nPwu09dARS8GrKmr_KtA-EHH5MD0ioAnyZ-cqf0q4,92160
|
|
16
|
+
ck/circuit_compiler/cython_vm_compiler/_compiler.cp312-win_amd64.pyd,sha256=nsx6Nz3p2P83RAvHORCxvdGHC8RaSRGbQhzg1bb6Dug,92160
|
|
19
17
|
ck/circuit_compiler/cython_vm_compiler/_compiler.pyx,sha256=hHuNo99TbodNpWgQwQ8qzW1cTwGXZj5SW0tKAo9u6cw,7718
|
|
20
18
|
ck/circuit_compiler/cython_vm_compiler/cython_vm_compiler.py,sha256=yUkBNr5HnoVXyWjJdXHp8lyAXFiIDYapvMvHtzKuhI8,3140
|
|
21
19
|
ck/circuit_compiler/support/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -87,8 +85,7 @@ ck/pgm_compiler/support/factor_tables.py,sha256=LAZbWtDVyTpxps7C4d3q38uUVkNnzRBO
|
|
|
87
85
|
ck/pgm_compiler/support/join_tree.py,sha256=tRHev655cwRsOSyLK9HYwfX8EEkubmlg1fw748Kztb4,10418
|
|
88
86
|
ck/pgm_compiler/support/named_compiler_maker.py,sha256=tQ79JOI8MknAziUiFhFGV9n4y6PPKrnbq3-quMmnrwY,974
|
|
89
87
|
ck/pgm_compiler/support/circuit_table/__init__.py,sha256=eWMP5ywgd51RJexKkhcpKJb_8iEluL0C4_hyOpzlAvQ,167
|
|
90
|
-
ck/pgm_compiler/support/circuit_table/circuit_table.
|
|
91
|
-
ck/pgm_compiler/support/circuit_table/circuit_table.cp312-win_amd64.pyd,sha256=TPzAAETE8QIjRp6yReo9YlNczibIBFQ6mu7KlTzUeXE,94720
|
|
88
|
+
ck/pgm_compiler/support/circuit_table/circuit_table.cp312-win_amd64.pyd,sha256=7Yc_Iqes51f7Q6lPyc2M1ysXeES0T8TkZaOf2ZbQoEc,94720
|
|
92
89
|
ck/pgm_compiler/support/circuit_table/circuit_table.pyx,sha256=jhzstay-3EUgu0CIbWKd0eNDNToX1tmm9IQxk0ZgpYM,11904
|
|
93
90
|
ck/pgm_compiler/support/circuit_table/circuit_table_py.py,sha256=1WFCxgBFu4oaYRCdk_1uXeufFQu6PqMOsYIQ_SkXDS4,10156
|
|
94
91
|
ck/probability/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -96,9 +93,9 @@ ck/probability/empirical_probability_space.py,sha256=HoLxmigzlWFWQlcZQwDOYk-mjgf
|
|
|
96
93
|
ck/probability/pgm_probability_space.py,sha256=vK-drx145PWW2aYB8HttQcvhvqPfxVl72bPcFO8jw8M,1034
|
|
97
94
|
ck/probability/probability_space.py,sha256=itv3dNEpSTLhKg6JCNhe7Iy6n9MKWqeKO4RxKR9kKF0,25882
|
|
98
95
|
ck/program/__init__.py,sha256=Ss9-0eqsGxCGloD6liH-0iqBG5Q3vPRF4XCw2hkDJ0M,110
|
|
99
|
-
ck/program/program.py,sha256=
|
|
96
|
+
ck/program/program.py,sha256=gDJ5Q2kXZuaoHboa9yNTg0tQH9S-Gmw0BRx6PPV28pU,4184
|
|
100
97
|
ck/program/program_buffer.py,sha256=1fiUcT7sqyr4vu8jXzK3ZsrgURFhWMdm6hr2BeS9ONA,5665
|
|
101
|
-
ck/program/raw_program.py,sha256=
|
|
98
|
+
ck/program/raw_program.py,sha256=1HA7k4V34LQg_KgYWs6XewHrtNiTRuL-ejNnki7oTho,2626
|
|
102
99
|
ck/sampling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
103
100
|
ck/sampling/forward_sampler.py,sha256=pTtpaH_ONH67G4P-aJ1p8YZSaXr4TTD6pj3ZEI2y7KM,8348
|
|
104
101
|
ck/sampling/marginals_direct_sampler.py,sha256=p1jDr1stG2Hjay3D8hILezW-5YZTX1p3odUcJDAI-OQ,4466
|
|
@@ -165,8 +162,8 @@ ck_demos/utils/compare.py,sha256=eC1rJXuWQhEfq4yQlXggn2O_sk-xAVEn6PpVuIaZJoo,344
|
|
|
165
162
|
ck_demos/utils/convert_network.py,sha256=TSKj8q7L7J5rhrvwjaDkdYZ0Sg8vV5FRL_vCanX1CQw,1363
|
|
166
163
|
ck_demos/utils/sample_model.py,sha256=in-Nlv-iuNIu6y9fDuMyo7nzgimBuTAnCWcpnVqvqDQ,8839
|
|
167
164
|
ck_demos/utils/stop_watch.py,sha256=VzXHRWx0V8vPSD-bLgLlEYkCkR2FA0-KmM_pfKx-Pxo,13205
|
|
168
|
-
compiled_knowledge-4.0.
|
|
169
|
-
compiled_knowledge-4.0.
|
|
170
|
-
compiled_knowledge-4.0.
|
|
171
|
-
compiled_knowledge-4.0.
|
|
172
|
-
compiled_knowledge-4.0.
|
|
165
|
+
compiled_knowledge-4.0.0a11.dist-info/licenses/LICENSE.txt,sha256=uMYx7tmroEKNASizbCOwPveMQsD5UErLDC1_SANmNn8,1089
|
|
166
|
+
compiled_knowledge-4.0.0a11.dist-info/METADATA,sha256=BwJQwg7IB8iA7mXWDo2aPDyWXz7jbfyZoUNJ2vNaXUM,1838
|
|
167
|
+
compiled_knowledge-4.0.0a11.dist-info/WHEEL,sha256=b7PoVIxzH_MOHKjftqMzQiGKfdHRlRFepVBVPg0y3vc,101
|
|
168
|
+
compiled_knowledge-4.0.0a11.dist-info/top_level.txt,sha256=Cf8DAfd2vcnLiA7HlxoduOzV0Q-8surE3kzX8P9qdks,12
|
|
169
|
+
compiled_knowledge-4.0.0a11.dist-info/RECORD,,
|