clab / clab/dynet

Ensure that expression are not stale in operations

Open
#527 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
3.4k
Forks
701
PR merge metrics
No merged PRs in 30d

Description

We should implement the `ensure_freshness` mechanism in c++.

My approach would be to replace the direct access to `pg` and `i` when building expressions by accessors in which we check that the computation graph of the expression is not dead.

Example :

Expression min(const Expression& x, const Expression& y) {
return Expression(x.pg, x.pg->add_function({x.i, y.i}));
}

becomes

Expression min(const Expression& x, const Expression& y) {
return Expression(x.pg(), x.pg()->add_function({x.i(), y.i()}));
}

Where `pg()` and `i()` can throw exceptions. Of course this will have a small overhead but it will prevent segfaults when using stale expressions.

Also once this is done we can remove `ensure_freshness` in python

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating C++ Expression operations that directly access `pg` and `i`, then trace the existing `ensure_freshness` mechanism. Check how stale computation graphs are detected and how the proposed `pg()` and `i()` accessors would affect expression construction. Done means operations use freshness-checked accessors and the Python `ensure_freshness` implementation can be removed without leaving stale-expression crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
machine-learning
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.