MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / get_shape_list

Function get_shape_list

examples/tensorflow/encoder/utils/encoder.py:135–155  ·  view source on GitHub ↗
(tensor, expected_rank=None, name=None)

Source from the content-addressed store, hash-verified

133 return output
134
135def get_shape_list(tensor, expected_rank=None, name=None):
136 if name is None:
137 name = tensor.name
138
139 if expected_rank is not None:
140 assert_rank(tensor, expected_rank, name)
141
142 shape = tensor.shape.as_list()
143
144 non_static_indexes = []
145 for (index, dim) in enumerate(shape):
146 if dim is None:
147 non_static_indexes.append(index)
148
149 if not non_static_indexes:
150 return shape
151
152 dyn_shape = tf.shape(tensor)
153 for index in non_static_indexes:
154 shape[index] = dyn_shape[index]
155 return shape
156
157def reshape_to_matrix(input_tensor):
158 """Reshapes a >= rank 2 tensor to a rank 2 tensor (i.e., a matrix)."""

Callers 3

tf_encoder_opennmtFunction · 0.70
reshape_from_matrixFunction · 0.70
ft_encoder_opennmtFunction · 0.70

Calls 1

assert_rankFunction · 0.70

Tested by

no test coverage detected