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

[TypeChecker][Relay] Issue with return type not being properly inferred. #6489

Closed
jroesch opened this issue Sep 16, 2020 · 3 comments
Closed
Labels
relay:ir src/relay/ir

Comments

@jroesch
Copy link
Member

jroesch commented Sep 16, 2020

cc @hypercubestart after I land #6274 there is an issue where omitting a return type now causes inference to fail, when you work on mutual recursion can you look into this?

 // (@jroesch): if we leave off the return type this doesn't work
/*
 * Computes the sum of a list of integer scalars.
 */
 // (@jroesch): if we leave off the return type this doesn't work
def @sum(%xs: List[Tensor[(), int32]]) -> int32 {
  let %add_f = fn(%x: Tensor[(), int32], %y: Tensor[(), int32]) -> Tensor[(), int32] {
    %x + %y
  };
  @foldl(%add_f, 0, %xs)
}
/*
 * Computes the size of a tree.
 */
def @size[A](%t: Tree[A]) -> Tensor[(), int32] {
  match(%t) {
    Rose(_, %sub_trees) => {
      1 + @sum(@map(@size, %sub_trees))
    },
  }
}
@jroesch
Copy link
Member Author

jroesch commented Sep 16, 2020

@jroesch
Copy link
Member Author

jroesch commented Sep 16, 2020

This also type checks:

/*
 * Reverses a list.
 */
def @rev[A](%xs: List[A]) -> List[A] {
  @foldl(@flip(fn (%h: A, %t: List[A]) { Cons(%h, %t) }), Nil, %xs)
}

This one doesn't type check.

/*
 * Reverses a list.
 */
def @rev[A](%xs: List[A]) -> List[A] {
  @foldl(@flip(Cons), Nil, %xs)
}

@tqchen
Copy link
Member

tqchen commented Nov 1, 2020

@jroesch please update to see if the issue can be closed

@areusch areusch added the needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it label Oct 19, 2022
@hpanda-naut hpanda-naut added relay:ir src/relay/ir and removed needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it labels Nov 28, 2022
@tqchen tqchen closed this as completed Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relay:ir src/relay/ir
Projects
None yet
Development

No branches or pull requests

4 participants