kups.core.effects.interpreter
¶
Interpreter
¶
Evaluate a jaxpr while threading a context through effect handlers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handlers
|
Mapping[Primitive | str, Handler[Context]]
|
Handler per primitive. Every equation of a listed primitive goes to its handler; all other primitives are bound unchanged. |
required |
effects
|
Collection[Primitive | str]
|
Primitives that perform effects. Applies |
()
|
policy
|
InterpreterPolicy
|
What to do with such an unreachable effect. |
RAISE
|
label
|
str
|
Name used in tracing debug info. |
''
|
Source code in src/kups/core/effects/interpreter.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
InterpreterPolicy
¶
Bases: Enum
What to do with an effect the interpreter cannot reach.
That is an effect primitive without a handler, or an unhandled primitive whose sub-jaxprs contain an effect primitive.
Source code in src/kups/core/effects/interpreter.py
IGNORE = 'ignore'
class-attribute
instance-attribute
¶
Bind the primitive unchanged. Its effects are lost.
RAISE = 'raise'
class-attribute
instance-attribute
¶
Raise NotImplementedError.
WARN = 'warn'
class-attribute
instance-attribute
¶
Warn, then bind the primitive unchanged. Its effects are lost.
bind_primitive(eqn, invals)
¶
Bind eqn's primitive to invals unchanged.