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

llvmlite error: Operands must be the same type, got (i32, i64) #659

Closed
vontell opened this issue Jan 24, 2017 · 5 comments
Closed

llvmlite error: Operands must be the same type, got (i32, i64) #659

vontell opened this issue Jan 24, 2017 · 5 comments

Comments

@vontell
Copy link

vontell commented Jan 24, 2017

For exceptions where an operation is attempted between an numpy.int32 and numpy.int64, there is no information (i.e. line number in my code) where the error occurs. Is there a way to enable more stacktrace information to find this error? Below is an example:

$ artiq_run repository/initialize-test.py 
Traceback (most recent call last):
  File "/home/artiq/anaconda3/envs/artiq-main/bin/artiq_run", line 11, in <module>
    load_entry_point('artiq==2.1', 'console_scripts', 'artiq_run')()
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/frontend/artiq_run.py", line 213, in main
    return run(with_file=True)
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/frontend/artiq_run.py", line 199, in run
    raise exn
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/frontend/artiq_run.py", line 192, in run
    exp_inst.run()
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/language/core.py", line 54, in run_on_core
    return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/coredevice/core.py", line 113, in run
    self.compile(function, args, kwargs, set_result)
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/coredevice/core.py", line 97, in compile
    library = target.compile_and_link([module])
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/compiler/targets.py", line 180, in compile_and_link
    return self.link([self.assemble(self.compile(module)) for module in modules],
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/compiler/targets.py", line 180, in <listcomp>
    return self.link([self.assemble(self.compile(module)) for module in modules],
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/compiler/targets.py", line 137, in compile
    llmod = module.build_llvm_ir(self)
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/compiler/module.py", line 84, in build_llvm_ir
    attribute_writeback=self.attribute_writeback)
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/compiler/transforms/llvm_ir_generator.py", line 408, in process
    self.process_function(func)
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/compiler/transforms/llvm_ir_generator.py", line 570, in process_function
    llinsn = getattr(self, "process_" + type(insn).__name__)(insn)
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/artiq/compiler/transforms/llvm_ir_generator.py", line 883, in process_Arith
    name=insn.name)
  File "/home/artiq/anaconda3/envs/artiq-main/lib/python3.5/site-packages/llvmlite_artiq/ir/builder.py", line 24, in wrapped
    % (lhs.type, rhs.type))
ValueError: Operands must be the same type, got (i32, i64)
@whitequark
Copy link
Contributor

For exceptions where an operation is attempted between an numpy.int32 and numpy.int64, there is no information (i.e. line number in my code) where the error occurs.

Most operations between np.int32 and np.int64 will result in the desired effect i.e. promotion. However, you've managed to find a bug in the compiler where that doesn't happen. This does not indicate a bug in your code (at least, this backtrace doesn't).

To fix this, I will need the specific code that causes the crash above.

@vontell
Copy link
Author

vontell commented Jan 24, 2017

My code begins with this initialize-test.py EnvExperiment. Before line 52, there is mostly just variable declaration, which has compiled fine in the past. On line 52 is a method rabi.get_photon_windows(), which I have also run and tested with no trouble.

Therefore, line 58 seems to be where the trouble begins. On this line, rabi.get_time_to_detect() is a call to the file rle/rabi.py. Lines 79 to 114 hold the relevant code, which none or little of which has code which may cause this issue.

The final destination is the method register_rising_in_window() in the file rle/pipistrello.py, and can be found on line 216 to 245.

Sorry that my methods pass many variables along the way (I have been running into errors where "variables might be uninitialized within closures"). My thoughts are that the error is most likely occurring somewhere in rabi.py, possibly in the record function which I use to store results from my experiment into an array. I can also reproduce the code here in this thread, but I didn't want to cause too much clutter.

Sorry, something went wrong.

@vontell
Copy link
Author

vontell commented Jan 24, 2017

The rotate() method of rabi.py may also be the culprit.

Sorry, something went wrong.

@vontell
Copy link
Author

vontell commented Jan 30, 2017

After some debugging, I have narrowed it down to the rotate() method:

@kernel
def rotate(self, array):
	'''Rotates an array, deleting the oldest value'''
	length = len(array)
	for i in range(np.int64(len(array)) - 1):
		array[length - i - 1] = array[length - i - 2]
	array[0] = 0

@vontell
Copy link
Author

vontell commented Jan 30, 2017

I have avoided this error by changing the rotate function to the following:

neg_one = np.int32(-1)
array[neg_one:] + array[:neg_one]

If I change the code to use neg_one = np.int64(-1), I get the error above, so I suppose it is related to the type needed for array access.

@whitequark whitequark changed the title Lack of information on stacktrace llvmlite error: Operands must be the same type, got (i32, i64) Jan 31, 2017
@sbourdeauducq sbourdeauducq added this to the 2.2 milestone Feb 1, 2017
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

3 participants