|
rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
|
Interpreter of a typing rule lowered to a descriptor. More...
#include <rexlib/core/operation/type_rule/type_rule_interpreter.hpp>
Interpreter of a typing rule lowered to a descriptor.
Deduces the data types of the outputs of an operation from the data types of its inputs, and decides whether outputs supplied in advance have admissible data types. Shapes are left alone.
Each call takes the data types the operation instance supplies, in the order the pivots reading them are declared.
deduce resolves the rule's pivots from the input types, checks every input against its slot and evaluates the output slots. resolve binds the rule's free pivots from the outputs as well and checks every operand, which admits the looser outputs a converting operation needs. It reports a rejection as a type_rule_resolution, and throw_error turns that into an exception. accept does both.
|
explicitnoexcept |
Construct an interpreter of a rule.
| rule | The rule. It must outlive the interpreter, which type_rule_descriptor_of guarantees by holding it in static storage. |
| void rexlib::type_rule_interpreter::accept | ( | const operation_descriptor & | descriptor, |
| span< const numerical_type > | operation_data_types, | ||
| span< const operand_specification > | user_outputs, | ||
| span< const operand_specification > | inputs | ||
| ) | const |
Decide whether outputs supplied in advance have admissible data types.
| descriptor | Description of the operation, used to name the operation and its operands when reporting a rejection. |
| operation_data_types | The data types the operation supplies. |
| user_outputs | The outputs supplied in advance, one per output slot. |
| inputs | The inputs, one per input slot. |
| std::invalid_argument | When the inputs or an output are not admissible. |
| void rexlib::type_rule_interpreter::check_instance | ( | const operation_descriptor & | descriptor, |
| span< const numerical_type > | operation_data_types | ||
| ) | const |
Check the data types an operation instance supplies.
| descriptor | Description of the operation, used to name it when reporting a rejection. |
| operation_data_types | The data types the operation supplies. |
| std::invalid_argument | When there are not as many as the rule reads, or one lies outside the domain of its pivot. |
| void rexlib::type_rule_interpreter::deduce | ( | const operation_descriptor & | descriptor, |
| span< const numerical_type > | operation_data_types, | ||
| span< operand_specification > | canonical_outputs, | ||
| span< const operand_specification > | inputs | ||
| ) | const |
Compute the data types of the outputs the inputs call for.
A data type the inputs do not determine is left as numerical_type::unknown.
| descriptor | Description of the operation, used to name the operation and its operands when reporting a rejection. |
| operation_data_types | The data types the operation supplies. |
| canonical_outputs | The outputs, one per output slot. Only their data types are set. |
| inputs | The inputs, one per input slot. |
| std::invalid_argument | When the inputs are not admissible. |
|
noexcept |
Resolve the rule against concrete operand data types.
| operation_data_types | The data types the operation supplies. |
| output_types | The data type of every output. |
| input_types | The data type of every input. |
| REXLIB_NORETURN void rexlib::type_rule_interpreter::throw_error | ( | const operation_descriptor & | descriptor, |
| const type_rule_resolution & | resolution | ||
| ) | const |
Turn a failed resolution into an exception.
| descriptor | Description of the operation, used to name the operation and its operands. |
| resolution | A failed resolution of this rule. |
| std::invalid_argument | Always. |