class ngraph::Evaluator


Execute handlers on a subgraph to compute values. More…

#include <evaluator.hpp>

template <typename V>
class Evaluator
    // typedefs

    typedef std::map<RawNodeOutput, V> value_map;
    typedef std::function<std::vector<V>(Node*op, std::vector<V>&inputs)> op_handler;
    typedef std::map<Node::type_info_t, op_handler> op_handler_map;

    // classes

    class ExecuteInst;
    class Inst;
    class ValueInst;

    // construction

    Evaluator(const op_handler_map& handlers, value_map& values);

    // methods

    value_map& get_value_map();
    const value_map& get_value_map() const;
    const op_handler& get_univeral_handler() const;
    const op_handler& get_default_handler() const;
    void set_univeral_handler(const op_handler& handler);
    void set_default_handler(const op_handler& handler);
    V evaluate(const Output<Node>& value);

Detailed Documentation

Execute handlers on a subgraph to compute values.


typedef std::map<RawNodeOutput, V> value_map

values we compute for outputs

typedef std::function<std::vector<V>(Node*op, std::vector<V>&inputs)> op_handler

Handler for a computation of a value about an op.

A handler is passed a Node* and a vector of computed input values. The handler should return a vector of computed output values.

typedef std::map<Node::type_info_t, op_handler> op_handler_map

Table of ops with handlers.


Evaluator(const op_handler_map& handlers, value_map& values)

construct handler using the provided op handlers.

Evaluations share previously computed values so that calls on multiple nodes can share work. All state is kept in the value map, which is accessible for clearing or seeding with Evaluator::get_value_map().



for ops. Pairs of Node::type_info_t and handler functions.


value_map& get_value_map()

Retrieves the value_map, which holds all Output<Node> value associations.

const op_handler& get_univeral_handler() const

If set, handles all ops.

const op_handler& get_default_handler() const

If set, handles all ops not in the handlers.

void set_univeral_handler(const op_handler& handler)

If set, handles all ops.

void set_default_handler(const op_handler& handler)

If set, handles all ops not in the handlers.

V evaluate(const Output<Node>& value)

Determine information about value.