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

[HYRID][SYNTAX] tir.allocate #95

Closed
tqchen opened this issue Aug 21, 2020 · 5 comments
Closed

[HYRID][SYNTAX] tir.allocate #95

tqchen opened this issue Aug 21, 2020 · 5 comments

Comments

@tqchen
Copy link
Contributor

tqchen commented Aug 21, 2020

Right now Allocate is printed as

def func():
    data = tir.var("handle")
    tir.allocate(data, "float32", [1024])

After apache/tvm#6317, we want to make sure that allocate actually uses var that has a pointer type annotation(non runtime type) to get richer information, it would be great to enhance hybrid parser to support this case.

A slight generalization might look like

def func():
    data = tir.var(ty.Ptr[ty.float32])
    tir.allocate(data, "float32", [1024])

However, it seems to be weird to separate data var declaration. In this case, we can simply do

def func():
    # data is a var with type annotation "Ptr[float32["
    data = tir.allocate("float32", [1024])  

and in the case of scoping

def func():
    with tir.allocate("float32", [1024]) as data:
@tqchen
Copy link
Contributor Author

tqchen commented Aug 21, 2020

cc @spectrometerHBH

@spectrometerHBH
Copy link
Collaborator

spectrometerHBH commented Aug 23, 2020

I encounter a problem now

The format now is

packedB = tir.var("handle")
tir.attr(packedB, "storage_scope", "global")
tir.allocate(packedB, "float32x32", [32768])

After compressing tir.allocate

tir.attr(packedB, "storage_scope", "global")
packedB = tir.allocate("float32x32", [32768])

From python's point of view, packedB is used before its declaration.

cc @tqchen

@Hzfengsy
Copy link
Member

Can we compress tir.allocate with attr together? As far as I know, every allocate will have an attr above it.

So, it could be

packedB = tir.allocate("float32x32", [32768], "global")

@tqchen
Copy link
Contributor Author

tqchen commented Aug 23, 2020

I agree in this case we should try to fold the storage scope into the allocate

@tqchen
Copy link
Contributor Author

tqchen commented Sep 6, 2020

@spectrometerHBH can you work a bit to resolve this issue? Thanks!

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

No branches or pull requests

3 participants