提交 9bf551d0 authored 作者: Harm de Vries's avatar Harm de Vries 提交者: Frederic Bastien

fix stride bug

上级 c708e3a5
...@@ -70,6 +70,8 @@ int APPLY_SPECIFIC(multinomial)(PyGpuArrayObject *pvals, ...@@ -70,6 +70,8 @@ int APPLY_SPECIFIC(multinomial)(PyGpuArrayObject *pvals,
{ // NESTED SCOPE { // NESTED SCOPE
int nb_multi = PyGpuArray_DIMS(pvals)[0]; int nb_multi = PyGpuArray_DIMS(pvals)[0];
printf("multinomail_test\n");
printf("%d\n",nb_multi);
int nb_outcomes = PyGpuArray_DIMS(pvals)[1]; int nb_outcomes = PyGpuArray_DIMS(pvals)[1];
//TODO : change this for a beautiful constant //TODO : change this for a beautiful constant
int max_nb_blocks = 2<<15 - 1; int max_nb_blocks = 2<<15 - 1;
...@@ -102,13 +104,13 @@ int APPLY_SPECIFIC(multinomial)(PyGpuArrayObject *pvals, ...@@ -102,13 +104,13 @@ int APPLY_SPECIFIC(multinomial)(PyGpuArrayObject *pvals,
PyGpuArray_DIMS(*out)[1], PyGpuArray_DIMS(*out)[1],
PyGpuArray_DIMS(*out)[0], PyGpuArray_DIMS(*out)[0],
(float*)PyGpuArray_DEV_DATA(pvals), (float*)PyGpuArray_DEV_DATA(pvals),
PyGpuArray_STRIDES(pvals)[0], PyGpuArray_STRIDES(pvals)[0]/sizeof(float),
PyGpuArray_STRIDES(pvals)[1], PyGpuArray_STRIDES(pvals)[1]/sizeof(float),
(float*)PyGpuArray_DEV_DATA(unis), (float*)PyGpuArray_DEV_DATA(unis),
PyGpuArray_STRIDES(unis)[0], PyGpuArray_STRIDES(unis)[0]/sizeof(float),
(float*)PyGpuArray_DEV_DATA(*out), (float*)PyGpuArray_DEV_DATA(*out),
PyGpuArray_STRIDES(*out)[0], PyGpuArray_STRIDES(*out)[0]/sizeof(float),
PyGpuArray_STRIDES(*out)[1] PyGpuArray_STRIDES(*out)[1]/sizeof(float)
); );
//TODO //TODO
......
...@@ -60,8 +60,9 @@ class GPUAMultinomialFromUniform(COp): ...@@ -60,8 +60,9 @@ class GPUAMultinomialFromUniform(COp):
return Apply(self, [pvals, unis], [out]) return Apply(self, [pvals, unis], [out])
def c_code_cache_version(self): # def c_code_cache_version(self):
return (8,) # return
# return (8,)
@register_opt() @register_opt()
......
...@@ -43,8 +43,9 @@ def test_multinomial0(): ...@@ -43,8 +43,9 @@ def test_multinomial0():
f = theano.function([p, u], m, mode=mode_with_gpu) f = theano.function([p, u], m, mode=mode_with_gpu)
theano.printing.debugprint(f) theano.printing.debugprint(f)
ret = f(numpy.array([[0.1, 0.2, 0.3, 0.4], ret = f(numpy.array([[0.1, 0.2, 0.3, 0.4],
[0.1, 0.2, 0.3, 0.4],
[0.1, 0.2, 0.3, 0.4]], dtype='float32'), [0.1, 0.2, 0.3, 0.4]], dtype='float32'),
numpy.array([0.05, 0.05], dtype='float32')) numpy.array([0.05, 0.05, 0.05], dtype='float32'))
print(numpy.asarray(ret)) print(numpy.asarray(ret))
...@@ -66,6 +67,7 @@ def test_multinomial_0(): ...@@ -66,6 +67,7 @@ def test_multinomial_0():
for node in f.maker.fgraph.toposort()]) for node in f.maker.fgraph.toposort()])
# test that both first and second samples can be drawn # test that both first and second samples can be drawn
print(f([[1, 0], [0, 1]], [.1, .1]))
utt.assert_allclose(f([[1, 0], [0, 1]], [.1, .1]), utt.assert_allclose(f([[1, 0], [0, 1]], [.1, .1]),
[[2, 0], [0, 2]]) [[2, 0], [0, 2]])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论