Prevent moving "gpu_from_host" outside of scan

Detect if the inner replacement would have a different type,
so that a new gpu_from_host is not inserted in the inner graph
in replacement of the one that was just pushed out.
Same change in sequence optimization
Merge pull request #1383 from lamblin/fix_scan_gpu_loop

Fix scan gpu loop
Fix-crash in scan grad when compute_test_value=raise

fix gh-1385
Add test.
Merge pull request #22 from lamblin/fix_crash

Add test
Merge pull request #1388 from nouiz/fix_crash

Fix-crash in scan grad when compute_test_value=raise
Better error message.
Don't reorder dimensions for elemwise when there is 0 or 1 dimensions.

this add extra useless code.
Add ScalarOp.c_code_contiguous interface and use it with exp.

Do this for amdlibm.

There is code for sigmoid, but it is disabled as it is slower.
Add contig version of pow, cos, sin, log, log2, log10
add amdlibm code for powx (pow(tensor, scalar))
fix test crash in debugmode.

it was triing the Image2Neibs.perform method for GpuImage2Neibs.
Fix Elemwise and CAReduce version when the scalar_op don't have a version.

We were not returning () when the scalar op don't have a version.
Merge pull request #1389 from nouiz/sigmoid

Sigmoid
Collections.Counter added for python < 2.7
better comment.
remove import not used.
Allow other file to reuse tensor/tests/test_basic.py:MakeTester
Add ultra_fast_sigmoid.