rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rexlib::shape_rule_interpreter Class Reference

Interpreter of a shape rule lowered to tables. More...

#include <rexlib/core/operation/shape_rule/shape_rule_interpreter.hpp>

Public Member Functions

 shape_rule_interpreter (const shape_rule_descriptor &rule) noexcept
 Construct an interpreter of a rule.
 
void check_instance (const operation_descriptor &descriptor, span< const std::size_t > named_axes, span< const std::size_t > operation_extents) const
 Check the values an operation instance supplies.
 
void deduce (const operation_descriptor &descriptor, span< const std::size_t > named_axes, bool keep_dimensions, span< const std::size_t > operation_extents, span< operand_specification > canonical_outputs, span< const operand_specification > inputs) const
 Compute the shapes of the outputs the inputs call for.
 
void accept (const operation_descriptor &descriptor, span< const std::size_t > named_axes, bool keep_dimensions, span< const std::size_t > operation_extents, span< const operand_specification > user_outputs, span< const operand_specification > inputs) const
 Decide whether outputs supplied in advance have admissible shapes.
 

Detailed Description

Interpreter of a shape rule lowered to tables.

Deduces the shapes of the outputs of an operation from the shapes of its inputs, and decides whether outputs supplied in advance have admissible shapes. Data types are left alone.

It knows nothing about operations or their parameters. Each call takes the values the rule reads from the operation instance:

See also
operand_shape_rule
shape_rule_descriptor_of

Constructor & Destructor Documentation

◆ shape_rule_interpreter()

rexlib::shape_rule_interpreter::shape_rule_interpreter ( const shape_rule_descriptor &  rule)
explicitnoexcept

Construct an interpreter of a rule.

Parameters
ruleThe lowered rule. It must outlive the interpreter, which shape_rule_descriptor_of guarantees by holding it in static storage.

Member Function Documentation

◆ accept()

void rexlib::shape_rule_interpreter::accept ( const operation_descriptor &  descriptor,
span< const std::size_t >  named_axes,
bool  keep_dimensions,
span< const std::size_t >  operation_extents,
span< const operand_specification >  user_outputs,
span< const operand_specification >  inputs 
) const

Decide whether outputs supplied in advance have admissible shapes.

Parameters
descriptorDescription of the operation, used to name the operation and its operands when reporting a rejection.
named_axesThe named axes.
keep_dimensionsWhether an output with no core axes keeps the named axes.
operation_extentsThe extents the operation supplies.
user_outputsThe outputs supplied in advance, one per output of the rule.
inputsThe inputs, one per input of the rule.
Exceptions
std::invalid_argumentWhen the inputs or an output are not admissible.
std::out_of_rangeWhen a named axis is beyond the rank of the inputs.

◆ check_instance()

void rexlib::shape_rule_interpreter::check_instance ( const operation_descriptor &  descriptor,
span< const std::size_t >  named_axes,
span< const std::size_t >  operation_extents 
) const

Check the values an operation instance supplies.

Checks what does not depend on the operands: how many axes are named and that none is named twice, and how many extents are supplied and that each lies in the domain of its variable.

Parameters
descriptorDescription of the operation, used to name it when reporting a rejection.
named_axesThe named axes.
operation_extentsThe extents the operation supplies.
Exceptions
std::invalid_argumentWhen a value is not admissible.

◆ deduce()

void rexlib::shape_rule_interpreter::deduce ( const operation_descriptor &  descriptor,
span< const std::size_t >  named_axes,
bool  keep_dimensions,
span< const std::size_t >  operation_extents,
span< operand_specification >  canonical_outputs,
span< const operand_specification >  inputs 
) const

Compute the shapes of the outputs the inputs call for.

Parameters
descriptorDescription of the operation, used to name the operation and its operands when reporting a rejection.
named_axesThe named axes.
keep_dimensionsWhether an output with no core axes keeps the named axes.
operation_extentsThe extents the operation supplies.
canonical_outputsThe outputs, one per output of the rule. Only their shapes are set.
inputsThe inputs, one per input of the rule.
Exceptions
std::invalid_argumentWhen the inputs are not admissible.
std::out_of_rangeWhen a named axis is beyond the rank of the inputs.

The documentation for this class was generated from the following file: