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

Function shape_internal

tensorflow/python/ops/array_ops.py:450–475  ·  view source on GitHub ↗

Returns the shape of a tensor. Args: input: A `Tensor` or `SparseTensor`. name: A name for the operation (optional). optimize: if true, encode the shape as a constant when possible. out_type: (Optional) The specified output type of the operation (`int32` or `int64`). Default

(input, name=None, optimize=True, out_type=dtypes.int32)

Source from the content-addressed store, hash-verified

448
449
450def shape_internal(input, name=None, optimize=True, out_type=dtypes.int32):
451 # pylint: disable=redefined-builtin
452 """Returns the shape of a tensor.
453
454 Args:
455 input: A `Tensor` or `SparseTensor`.
456 name: A name for the operation (optional).
457 optimize: if true, encode the shape as a constant when possible.
458 out_type: (Optional) The specified output type of the operation (`int32` or
459 `int64`). Defaults to tf.int32.
460
461 Returns:
462 A `Tensor` of type `out_type`.
463
464 """
465 with ops.name_scope(name, "Shape", [input]) as name:
466 if isinstance(
467 input, (sparse_tensor.SparseTensor, sparse_tensor.SparseTensorValue)):
468 return gen_math_ops.cast(input.dense_shape, out_type)
469 else:
470 if not context.executing_eagerly():
471 input_tensor = ops.convert_to_tensor(input)
472 input_shape = input_tensor.get_shape()
473 if optimize and input_shape.is_fully_defined():
474 return constant(input_shape.as_list(), out_type, name=name)
475 return gen_array_ops.shape(input, name=name, out_type=out_type)
476
477
478@tf_export("shape_n")

Callers 4

shapeFunction · 0.85
zeros_like_implFunction · 0.85
ones_like_implFunction · 0.85
searchsortedFunction · 0.85

Calls 8

constantFunction · 0.90
executing_eagerlyMethod · 0.80
is_fully_definedMethod · 0.80
name_scopeMethod · 0.45
castMethod · 0.45
get_shapeMethod · 0.45
as_listMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected