-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[RELAY][TRANSFORM] Migrate buildmodule to transform #3251
Conversation
I dont think type inference should be a pass. It should be something we always call pre/post to doing anything. |
also can you rebase? |
TypeInference could be a pass that can be required by some other passes |
@MarisaKirisame Yes, I also think TypeInference should be a pass. Otherwise, we have to force to execute it explicitly. |
I think it should be implicit, and all pass will call it pre/post the pass (this is register in passmanager.cc). |
c674ed7
to
1d37f52
Compare
@MarisaKirisame Yeah, I see your point, but shouldn't be better to add it to the required list and invoke it only when necessary? |
@zhiics dont think of it as an analysis; think of it as a safety check. |
9d55501
to
25fcc77
Compare
I think @MarisaKirisame's point makes sense at some extend. But I still think it might be more appropriate to add TypeInference as a required pass and apply it when necessary. If we want to do safety check before every pass, we should probably encode type inference there. In the future, we may need to do pass validation after optimization where type inference might be explicitly called any way. @MarisaKirisame Do you think this is okay? @tqchen @jroesch thoughts? |
As a side note, to demonstrate the flexibility of the new transform API. I hope we can revive relay.build in python, which calls into the transform API without calling into C++. This is a slight divergence but given that the code is short enough, I believe a useful thing to do. Eventually, we can also have a DefaultOptPipeline that returns the default sequential pipeline we use for optimization. |
bcd2bec
to
51f6013
Compare
Doesn't this actively work against the goal to have a pure C++ pipeline for the compiler? |
What I mean is to have a python pipeline alone with the c++ one, given both of them are short enough, we want to make sure it is easy to customize compilation pipeline from python |
yeah, we can probably have a separate discussion about adding the parallel optimization pipeline. Currently, we can finish the migration and clean up |
51f6013
to
0e09241
Compare
0e09241
to
83c2527
Compare
@tqchen Now all passes are moved to |
3b64482
to
a845b0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
I can merge this in as it is clearly an improvement over what we had before. However, I am still not happy with the Optimize. Here is a mock example of an "ideal code" of optimize: # mostly device invariant optimizations
opt = transform.Sequential([
transform.FoldConstant(),
transform.SimplifyInference(),
transform.EnableIf(lambda ctx: len(ctx.targets) == 1, transform.AlterLayout()),
])
# target specific optimizations
lower = transform.Sequential([
transform.DeviceAnnotation(), # only enables for multiple target
transform.FuseOps()
])
with transform.PassContext(target=target_device_map):
mod = optimzie(mod)
mod = lower(mod) This is only a quick alternative that pops out from my head. @zhiics feel free to the critic. But we should really move to minimize the code of this lowering process. Also cc @merrymercy @vinx13 @yzhliu @jroesch for more thoughts, perhaps we could use another RFC if necessary :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some further nits
Sorry. I totally missed this. I totally agree with you that it makes sense to separate target dependent and independent opts. Actually, I have been thinking of this as well. We can probably have another RFC for it. But let us keep this code change minimum for now. |
44f81ed
to
940eb96
Compare
This PR is the second item of #3202. We focus on the following items
RelayBuildConfig
inBuildModule
and replace them withPassContext
.Optimize
toSequential
inBuildModule
.Sequential
usingWith
scoping.cc @tqchen @jroesch @MarisaKirisame @wweic @icemelon9