MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / tile

Function tile

tensorflow/python/ops/ragged/ragged_array_ops.py:208–248  ·  view source on GitHub ↗

Constructs a `RaggedTensor` by tiling a given `RaggedTensor`. The values of `input` are replicated `multiples[i]` times along the `i`th dimension (for each dimension `i`). For every dimension `axis` in `input`, the length of each output element in that dimension is the length of correspond

(input, multiples, name=None)

Source from the content-addressed store, hash-verified

206# Tiling
207#===============================================================================
208def tile(input, multiples, name=None): # pylint: disable=redefined-builtin
209 """Constructs a `RaggedTensor` by tiling a given `RaggedTensor`.
210
211 The values of `input` are replicated `multiples[i]` times along the
212 `i`th dimension (for each dimension `i`). For every dimension `axis` in
213 `input`, the length of each output element in that dimension is the
214 length of corresponding input element multiplied by `multiples[axis]`.
215
216 Args:
217 input: A `RaggedTensor`.
218 multiples: A 1-D integer `Tensor`. Length must be the same as the number of
219 dimensions in `input`.
220 name: A name for the operation (optional).
221
222 Returns:
223 A `RaggedTensor` with the same type, rank, and ragged_rank as `input`.
224
225 #### Example:
226 ```python
227 >>> rt = tf.ragged.constant([[1, 2], [3]])
228 >>> ragged.tile(rt, [3, 2])
229 [[1, 2, 1, 2], [3, 3], [1, 2, 1, 2], [3, 3], [1, 2, 1, 2], [3, 3]]
230 ```
231 """
232 with ops.name_scope(name, 'RaggedTile', [input, multiples]):
233 input = ragged_tensor.convert_to_tensor_or_ragged_tensor(
234 input, name='input')
235 if not ragged_tensor.is_ragged(input):
236 return array_ops.tile(input, multiples, name)
237 multiples = ragged_util.convert_to_int_tensor(
238 multiples, name='multiples', dtype=input.row_splits.dtype)
239 multiples.shape.assert_has_rank(1)
240
241 # If the constant value of `multiples` is available, then we can use it
242 # to skip tiling dimensions where `multiples=1`.
243 const_multiples = tensor_util.constant_value(multiples)
244
245 return ragged_tensor.RaggedTensor.from_nested_row_splits(
246 _tile_ragged_values(input, multiples, const_multiples),
247 _tile_ragged_splits(input, multiples, const_multiples),
248 validate=False)
249
250
251def _tile_ragged_values(rt_input, multiples, const_multiples=None):

Callers 2

batch_gather_ndFunction · 0.50
tile_one_dimensionFunction · 0.50

Calls 7

_tile_ragged_valuesFunction · 0.85
_tile_ragged_splitsFunction · 0.85
is_raggedMethod · 0.80
tileMethod · 0.80
assert_has_rankMethod · 0.80
name_scopeMethod · 0.45

Tested by

no test coverage detected