def test_concatenate(): ac, ag = gen_gpuarray((2, 2), 'float32', ctx=context) bc, bg = gen_gpuarray((1, 2), 'float32', ctx=context) rc = numpy.concatenate((ac, bc), axis=0) rg = pygpu.concatenate((ag, bg), axis=0) numpy.testing.assert_allclose(rc, numpy.asarray(rg)) rc = numpy.concatenate((ac, bc.T), axis=1) rg = pygpu.concatenate((ag, bg.T), axis=1) numpy.testing.assert_allclose(rc, numpy.asarray(rg))
def perform(self, node, axis_and_tensors, out_, ctx): out, = out_ axis = int(axis_and_tensors[0]) if axis < 0: axis += axis_and_tensors[1].ndim tensors = axis_and_tensors[1:] out[0] = pygpu.concatenate(tensors, axis=axis, context=ctx).astype( node.outputs[0].dtype)
def perform(self, node, axis_and_tensors, out_, ctx): out, = out_ axis = int(axis_and_tensors[0]) if axis < 0: axis += axis_and_tensors[1].ndim tensors = axis_and_tensors[1:] out[0] = pygpu.concatenate(tensors, axis=axis, context=ctx).astype(node.outputs[0].dtype)
def perform(self, node, axis_and_tensors, out_, ctx): out, = out_ view = self.view axis = int(axis_and_tensors[0]) tensors = axis_and_tensors[1:] if axis < -axis_and_tensors[1].ndim: raise IndexError if axis < 0: axis += axis_and_tensors[1].ndim # we check these tensors for being empty. if (view != -1) and numpy.all( [tensor.shape[axis] == 0 for tensor in tensors[0:view] + tensors[view + 1:]]): out[0] = tensors[view] else: out[0] = pygpu.concatenate(tensors, axis=axis, context=ctx).astype( node.outputs[0].dtype)
def perform(self, node, axis_and_tensors, out_, ctx): out, = out_ view = self.view axis = int(axis_and_tensors[0]) tensors = axis_and_tensors[1:] if axis < -axis_and_tensors[1].ndim: raise IndexError if axis < 0: axis += axis_and_tensors[1].ndim # we check these tensors for being empty. if (view != -1) and np.all( [tensor.shape[axis] == 0 for tensor in tensors[0:view] + tensors[view + 1:]]): out[0] = tensors[view] else: out[0] = pygpu.concatenate(tensors, axis=axis, context=ctx).astype( node.outputs[0].dtype)
def perform(self, node, axis_and_tensors, out_): out, = out_ axis = int(axis_and_tensors[0]) tensors = axis_and_tensors[1:] out[0] = pygpu.concatenate(tensors, axis=axis).astype( node.outputs[0].dtype)