def _oper_gpu(cls, x, pz, ps, w, wr, wc, b):
        if ps is None:
            s_p = GPUValue(shape=(x.shape[0], w.shape[1] // 4)).zeros_like_me()
            z_p = s_p.zeros_like_me()
        else:
            s_p, z_p = map(get_gpu, (ps, pz))

        s = s_p.empty_like_me()
        u = op.dot(x, w) + op.dot(z_p, wr)
        if b is not None:
            u += b

        u = get_gpu(u)
        z = z_p.zeros_like_me()
        cu.cupeepholelstm_forward(u, get_gpu(wc), s_p, s, z)

        ret = cls._create_node(z)
        ret.attrs._x = x
        ret.attrs._w = w
        ret.attrs._wr = wr
        ret.attrs._wc = wc
        ret.attrs._b = b
        ret.attrs._u = u
        ret.attrs._pz = pz
        ret.attrs._pstate = ps
        ret.attrs._state = s

        if isinstance(pz, Node):
            pz.attrs._pfgate = u
        return ret
Beispiel #2
0
 def _oper_gpu(cls, x, rois, ch, h, w, n_rois, outh, outw, spatial_scale):
     z = GPUValue(shape=(n_rois, ch, outh, outw))
     argmax_data = z.empty_like_me()
     rois = get_gpu(rois)
     cu.curoi_pool2d_forward(rois, get_gpu(x), spatial_scale, ch, h, w,
                             outh, outw, z, argmax_data)
     ret = cls._create_node(z)
     ret.attrs._index = argmax_data
     ret.attrs._x = x
     ret.attrs._rois = rois
     ret.attrs._outh = outh
     ret.attrs._outw = outw
     ret.attrs._spatial_scale = spatial_scale
     return ret