question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[RFC][Relay] Pass API Discussion

See original GitHub issue

In #2512 , we had decided on the API on Pass Manager. However, in personal communication with @tqchen , he suggested that we think on the name a bit (what namespace, what is the name of class and function, etc).

Example Code

python

from tvm import relay

x = relay.var("x")
y = relay.add(x, x)
f = relay.Function([x], y)

mod = relay.Module({"main": f})
# NOTE: infer type will be automatically populated in the future
seq = relay.transform.Sequential(
    relay.transform.InferType(),
    relay.transform.DebugPrintText(),
    relay.transform.FoldConstant(),
    relay.transform.AlterOpLayout(),
)
with relay.build_config(opt_level=3):
     mod = seq(mod)

C++

relay::Module Transform(relay::Module mod) {
  auto seq = relay::transform::Sequential({
    relay::transform::InferType(),
    relay::transform::DebugPrintText(),
    relay::transform::FoldConstant(),
        relay::transform::AlterOpLayout()});

   { 
     relay::BuildConfigContext bctx(relay.BuildConfig(opt_level=3));
      return seq(mod);
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
tqchencommented, May 17, 2019

Let me elaborated a bit. While #2546 has decided most details about the pass manager internals, I would like us to think a bit more about the API design itself. In particular, how to learn from deep learning frameworks(pytorch, keras, gluon) to build an API that is intuitive, friendly and requires the users to write a minimum amount of code.

During a conversation with @MarisaKirisame and others, we try to mock up what the usage of the code looks like, and we try to model it relatively similar to pytorch (see updated example).

I think we should iterate on the API designs. At the current moment, we have quite a few boiler-plate in relay.build_module etc. that I hope eventually we can simplify with just the consistent elegant code.

The transform namespace arises from the idea to be consistent with MLIR. MLIR tries to separate pass into two categories(transforms: Module->Module, analysis; Module->AnalysisResult). I think it is a good separation that we could learn from. It also avoids the problem of pass being a keyword in python.

We could use transform namespace as a new namespace to implement such change, we keep the original API, and migrate over after we fully support the transform API and remove the original ir_pass.py

2reactions
zhiicscommented, May 17, 2019

Sounds like a good plan. I think main is currently used as the entry function by default, right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Re: [dmlc/tvm] [RFC][Relay] Pass API Discussion ... - The Mail Archive
Things to discuss: - API mock-up example, syntax - namespace convention - keyword for the entry function in Module(main?) -- You are receiving...
Read more >
[RFC] Relay C++ Frontend · Issue #2685 · apache/tvm
In production environment, usually it is pure C++ environment. We are working out a pure C++ relay frontend. I want to know whether...
Read more >
[RFC][Relay] Program Matching for Relay Pt 1: A pattern ...
This API takes set of patterns describing your hardware capabilities and an external compiler, providing a relatively smooth heterogeneous experience out of the ......
Read more >
Answer Questions - Cisco Community
Hi Team, Can anyone help me to create an agent in Cicso unified contact center management portal (CCMP) using rest api?
Read more >
REST API: Create Forum Topic | Communifire Documentation
Creates a forum topic (discussion). ... REST API: Create Forum Topic ... Please Note Pass application/json as the content type in the header ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found