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

AttributeError: 'float' object has no attribute '__name__' #9

Open
mohdsm81 opened this issue Feb 23, 2013 · 1 comment
Open

AttributeError: 'float' object has no attribute '__name__' #9

mohdsm81 opened this issue Feb 23, 2013 · 1 comment

Comments

@mohdsm81
Copy link

Hi,

Can you please point me to how to fix it or at least where to begin and what reasons causing this? (thanks a lot in advance and all the best)

I was trying to run my blackscholes.py that i implemented from scratch different from original implementation. I use an array of numpy.float64 tuple values to compute results. However when I run it, copperhead gives me the following trace although python interpreter works perfectly:

Trying to read file (" inputs/in_4.txt ") content into a list ...

Now moving data into heterogeneous memory spaces using copperhead.cuarray ...

Stock prices computed:

Now computing CPU prices ...
CPU: [9.0956624056554016, 5.1448393856839623, 4.8148864021584643, 9.6919439520870583]
Time (sec): 0.000427961349487
Now computing CPU-OpenMP prices ...

ERROR during compilation in gather_source
def computeAll(optionDataCuarray):
return map(BlkSchlsEqEuroNoDiv, optionDataCuarray)

ERROR during compilation in frontend
def computeAll(optionDataCuarray):
return map(BlkSchlsEqEuroNoDiv, optionDataCuarray)
Traceback (most recent call last):
File "blackscholes.py", line 285, in
main()
File "blackscholes.py", line 266, in main
cpu_omp = computeAll(optionDataCuarray)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/cufunction.py", line 58, in call
return P.execute(self, args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/driver.py", line 57, in execute
return execute(self.tag(), cufn, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/runtime/driver.py", line 131, in execute
**k)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/passes.py", line 292, in compile
return run_compilation(target, source, M)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/passes.py", line 270, in run_compilation
return target(suite, M)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/passes.py", line 91, in call
ast = P(ast, M)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/passes.py", line 91, in call
ast = P(ast, M)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/passes.py", line 130, in gather_source
return Front.gather_source(ast, M)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/rewrites.py", line 104, in gather_source
gathered = gatherer.gather(stmt)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/rewrites.py", line 62, in gather
self.clean.insert(0, self.rewrite(stmt))
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 394, in rewrite
return [self.rewrite(y) for y in x]
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 399, in rewrite
rewritten = fn(x_copy)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/rewrites.py", line 71, in _Procedure
self.rewrite_children(proc)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 384, in rewrite_children
x.parameters = self.rewrite(x.parameters)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 394, in rewrite
return [self.rewrite(y) for y in x]
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 399, in rewrite
rewritten = fn(x_copy)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/rewrites.py", line 82, in _Bind
self.rewrite_children(bind)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 384, in rewrite_children
x.parameters = self.rewrite(x.parameters)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 394, in rewrite
return [self.rewrite(y) for y in x]
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 399, in rewrite
rewritten = fn(x_copy)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 406, in _default
return self.rewrite_children(x)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 384, in rewrite_children
x.parameters = self.rewrite(x.parameters)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 394, in rewrite
return [self.rewrite(y) for y in x]
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/coresyntax.py", line 399, in rewrite
rewritten = fn(x_copy)
File "/usr/local/lib/python2.7/dist-packages/copperhead-0.2a2-py2.7.egg/copperhead/compiler/rewrites.py", line 89, in _Name
if (fn.name in self.prelude_impl):
AttributeError: 'float' object has no attribute 'name'

@dybber
Copy link

dybber commented May 2, 2013

I also get this error quite often and it seems that several things can cause this error to appear.

  • Using a function that does not have a Copperhead equivalent (e.g. using pow(a,b))
  • Using a globally defined variable inside a Copperhead expression

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

2 participants