def test_cpu_tile_reverse(self): res = xdl.tile(embeds, idx, values, segs, grps, length=length, reverse=True) res = xdl.execute(res) res_tile = np.array([[1.2, 0.4, 0.3], [0.4, 0.0, 0.0], [3.0, 1.0, 0.0], [0.0, 0.0, 0.0], [3.0, 5.4, 3.2]], dtype=np.float) self.assertTrue(np.allclose(res, res_tile))
def test_cpu_tile_empty_value_reverse(self): empty_values = np.array([], dtype=np.float) res = xdl.tile(embeds, idx, empty_values, segs, grps, length=length, reverse=True) res = xdl.execute(res) res_tile = np.array([[0.4, 0.2, 0.3], [0.1, 0.0, 0.0], [0.5, 0.2, 0.0], [0.0, 0.0, 0.0], [0.3, 0.6, 0.4]], dtype=np.float) self.assertTrue(np.allclose(res, res_tile))
def test_gpu(self): with xdl.device("GPU"): res = xdl.tile(embeds, idx, values, segs, grps, length=length, reverse=False) res = xdl.execute(res) res_tile = np.array([[0.3, 0.4, 0.0, 0.0, 0.0, 0.0], [1.2, 0.0, 0.0, 0.4, 0.0, 0.0], [1.0, 3.0, 0.0, 0.7, 3.2, 5.4]], dtype=np.float) self.assertTrue(np.allclose(res, res_tile))
def test_gpu_tile_empty_value(self): with xdl.device("GPU"): empty_values = np.array([], dtype=np.float) res = xdl.tile(embeds, idx, empty_values, segs, grps, length=length, reverse=False) res = xdl.execute(res) res_tile = np.array( [[0.3, 0.2, 0.4], [0.1, 0.0, 0.0], [0.2, 0.5, 0.0], [0.0, 0.0, 0.0], [0.1, 0.4, 0.6]], dtype=np.float) self.assertTrue(np.allclose(res, res_tile))
def tile(embeddings, idx, values, segments, length, reverse=False, device='CPU', **device_attrs): groups = np.array([], dtype=dtype_xdl_2_np(segments.dtype)) with xdl.device(device, **device_attrs): res = xdl.tile(embeddings, idx, values, segments, groups, reverse=reverse, length=length) return res
def merged_tile(embeddings, idx, values, segments, groups, length, reverse=False, device='CPU', **device_attrs): with xdl.device(device, **device_attrs): res = xdl.tile(embeddings, idx, values, segments, groups, reverse=reverse, length=length) return res
def merged_tile(embeddings, idx, values, segments, groups, length, reverse=False): return xdl.tile(embeddings, idx, values, segments, groups, reverse=reverse, length=length)
def tile(embeddings, idx, values, segments, length, reverse=False): groups = np.array([], dtype=dtype_xdl_2_np(segments.dtype)) return xdl.tile(embeddings, idx, values, segments, groups, reverse=reverse, length=length)