Skip to content

Conversation

@MarisaKirisame
Copy link
Contributor

@MarisaKirisame MarisaKirisame commented Aug 3, 2019

This PR:

  • Fix Partial Evaluator for letrec program.
  • Generalize Time into arbitary Meet semilattice with finite descending chain. Now people can modify the termination checker to be more aggressive (inline more) or conservative (inline less, save more time) with little ease.
  • Implement the FTValue - it look into a partially static value, and if it is a positive scalar integer, use the value as fuel (allow decrease on it).
  • Simplify Dead Code Eliminator.
  • Fix an Error in DCE - the old one use a worklist which does not play well with WithRec because it will escape the scope. Now there is no concept of recursion in DCE.
  • Reenable a test in DCE.
  • Fix alpha equal for letrec program.
  • Fix ToGraphNormalForm for letrec program.
    @jroesch @tmoreau89 @weberlo

lint some

lint

lint

add charrnn

save

save

save

remove debug

remove debug

remove space

refactor

save

rewrite dce
@MarisaKirisame MarisaKirisame changed the title Pe inline scalar [Relay] Pe inline scalar Aug 3, 2019
@tmoreau89
Copy link
Contributor

Thanks for the PR @MarisaKirisame, could you fix the title to "[Relay] PE inline scalar" and in the description spell out "Partial evaluation" so people can get context?

@MarisaKirisame MarisaKirisame changed the title [Relay] Pe inline scalar [Relay] PE inline scalar Aug 3, 2019
@MarisaKirisame
Copy link
Contributor Author

@tmoreau89 thx! It is done.

Copy link
Contributor

@weberlo weberlo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarisaKirisame This PR looks sick!

I think you forgot to change the title to "Partial evaluation" instead of "PE". Also, it looks like there's more than just scalar inlining in here. A more descriptive title might be "[Relay] Extend coverage of partial evaluation".

return Fuel(make_node<FTValueNode>(tvalue));
}

/*! \brief Initially every element has Fuel of FBottom. It is the smallest element.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the code or lattices very well yet, but if every element starts at FBottom, and you only do meets, then wouldn't it remain FBottom forever, since the meet of a minimal element and any other element is always the minimal element?

If that's the case, then maybe this should be FTop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! It is indeed FTop. It was initally 'finitely ascending' but that sound strange, so I flip the lattice to match that.

auto ret = Meet(f, &progress);
return std::make_tuple(ret, progress);
}
/*! \brief return the new Fuel, and write true only iff progress is made. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/*! \brief return the new Fuel, and write true only iff progress is made. */
/*! \brief return the new Fuel, and write true iff progress is made. */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to communicate that if progress is already true, in no case it will be written false. I will rewordsmith.

f_var = Var("f")
f = Function([x], If(op.equal(x, const(0)), const(0), x + f_var(x - const(1))))
orig = run_infer_type(Let(f_var, f, f_var(const(10))))
assert_alpha_equal(dcpe(orig), const(55))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this called test_triangle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

triangle number

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change it to test_triangular_number?

@MarisaKirisame MarisaKirisame changed the title [Relay] PE inline scalar [Relay] Partial Evaluator do concatenate, and has better termination checker for scalar. Aug 5, 2019

class FuelNode;
/*! \brief A meet-semilattice with finite descending chain.
* It mean that we can meet two element to get an element,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

means

class FuelNode;
/*! \brief A meet-semilattice with finite descending chain.
* It mean that we can meet two element to get an element,
* and for every element, there is only finite amount of meet before getting back the same element.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only a finite

* and for every element, there is only finite amount of meet before getting back the same element.
*
* Every time we recurse, we do a meet and require that progress must be made.
* This make sure we do not recurse infinitely in the Partial Evaluator.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures

Expr PostProcess(const Expr&);

/*! \brief The base container type of Relay values. */
/*! \brief A StaticNode contain some static data that the Partial Evaluator can use. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contains

@tmoreau89 tmoreau89 merged commit c8654e2 into apache:master Aug 5, 2019
@MarisaKirisame MarisaKirisame deleted the pe-inline-scalar branch August 6, 2019 19:53
wweic pushed a commit to wweic/tvm that referenced this pull request Aug 9, 2019
…checker for scalar. (apache#3703)

* save

lint some

lint

lint

add charrnn

save

save

save

remove debug

remove debug

remove space

refactor

save

rewrite dce

* reset files

* join -> meet

* lint

* address review comment

* wordsmith
wweic pushed a commit to neo-ai/tvm that referenced this pull request Sep 6, 2019
…checker for scalar. (apache#3703)

* save

lint some

lint

lint

add charrnn

save

save

save

remove debug

remove debug

remove space

refactor

save

rewrite dce

* reset files

* join -> meet

* lint

* address review comment

* wordsmith
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.

3 participants