Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: subgraphs within graph #235

Merged
merged 6 commits into from
May 12, 2023
Merged

feat: subgraphs within graph #235

merged 6 commits into from
May 12, 2023

Conversation

alexander-camuto
Copy link
Collaborator

@alexander-camuto alexander-camuto commented May 12, 2023

The Scan op in tract defines subgraphs within a graph. This is how, in particular, recursive models like RNNs and LSTMs are represented. Here we introduce the ability for models to be nodes of a larger meta-model.

This is done by defining:

/// Enables model as subnode of other models
#[derive(Clone, Debug)]
pub enum NodeType<F: PrimeField + TensorType + PartialOrd> {
    /// A node in the model
    Node(Node<F>),
    /// A submodel
    SubGraph {
        /// The subgraph
        graph: Model<F>,
        /// The subgraph's inputs
        inputs: Vec<usize>,
        /// the subgraph's idx within the parent graph
        idx: usize,
    },
}

The Nodes of a models are then:

/// Representation of execution graph
pub type NodeGraph<F> = BTreeMap<usize, NodeType<F>>;

This enables us to define 99% of LSTM / RNN layers. Resolving most of #164

Remaining OPs to implement are concat and slice :)

@alexander-camuto alexander-camuto marked this pull request as ready for review May 12, 2023 22:19
@alexander-camuto alexander-camuto merged commit 2a4dbc7 into main May 12, 2023
@alexander-camuto alexander-camuto deleted the ac/cleanup-tract-facts branch May 13, 2023 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant