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