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

Static + Method: Hangs nim compilation (and zombifies nim process) #6078

Closed
mratsim opened this issue Jul 9, 2017 · 4 comments
Closed

Static + Method: Hangs nim compilation (and zombifies nim process) #6078

mratsim opened this issue Jul 9, 2017 · 4 comments
Assignees

Comments

@mratsim
Copy link
Collaborator

mratsim commented Jul 9, 2017

The following snippet will hang nim compilation.
Nim processes will consume a lot of Cpu and must be killed manually.

The strange thing is that to compile, I can uncomment:

  • either the method
  • or the tensor object creation (with static generic)
type
  Backend* = enum
    Cpu

  Tensor*[B: static[Backend]; T] = object
    data: seq[T]


proc toTensor*[T](s:openarray[T], B: static[Backend]): Tensor[B,T] =
  result.data = @s


####
type Autograd = ref object of RootObj

method forward[B,T](self: Autograd, list_tensors: varargs[Tensor[B,T]]): T {.base.}=
  raise newException(ValueError, "Forward is not implemented for this function")

type AddFn = ref object of Autograd


## Commenting either the following will make the program compiles
method forward[B,T](self: AddFn, a, b: Tensor[B,T]): T =
  return 1 + 1

## Or commenting the following will make the program compiles
let a = [0,1,2,3,4,5].toTensor(Cpu)

Without static at all, everything compiles.

type
  Backend* = enum
    Cpu

  Tensor*[T] = object
    data: seq[T]


proc toTensor*[T](s:openarray[T]): Tensor[T] =
  result.data = @s


####
type Autograd = ref object of RootObj

method forward[T](self: Autograd, list_tensors: varargs[Tensor[T]]): T {.base.}=
  raise newException(ValueError, "Forward is not implemented for this function")

type AddFn = ref object of Autograd


## No issue
method forward[T](self: AddFn, a, b: Tensor[T]): T =
  return 1 + 1

## No issue
let a = [0,1,2,3,4,5].toTensor()

I'm using Nim 0.17 on MacOS (install by choosenim stable)

@subsetpark
Copy link
Contributor

subsetpark commented Jul 9, 2017

Reproduced on Linux with:

Nim Compiler Version 0.17.1 (2017-07-08) [Linux: amd64]
Copyright (c) 2006-2017 by Andreas Rumpf

active boot switches: -d:release

@narimiran
Copy link
Member

Nim processes will consume a lot of Cpu and must be killed manually.

Nim v0.19.0, Linux, raises: "Error: generic instantiation too nested"

@andreaferretti
Copy link
Collaborator

Compiles fine on MacOS devel da4215a

@narimiran
Copy link
Member

narimiran commented Oct 11, 2018

Compiles fine on MacOS devel

Confirmed on Linux with the latest devel — compilation is successful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants