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

Method __init__

tensorflow/python/tpu/tpu_feed.py:133–198  ·  view source on GitHub ↗

Creates a new InfeedQueue with the given configuration. The configuration need not be fully specified at creation since it can be modified subsequently by methods that set the values explicitly or infer them from the shapes of inputs. Args: number_of_tuple_elements: the numbe

(self,
               number_of_tuple_elements=None,
               tuple_types=None,
               tuple_shapes=None,
               shard_dimensions=None,
               name=None)

Source from the content-addressed store, hash-verified

131 """
132
133 def __init__(self,
134 number_of_tuple_elements=None,
135 tuple_types=None,
136 tuple_shapes=None,
137 shard_dimensions=None,
138 name=None):
139 """Creates a new InfeedQueue with the given configuration.
140
141 The configuration need not be fully specified at creation since it
142 can be modified subsequently by methods that set the values
143 explicitly or infer them from the shapes of inputs.
144
145 Args:
146 number_of_tuple_elements: the number of Tensors fed atomically through the
147 queue, must be present unless it can be inferred from other arguments.
148 tuple_types: if not None, a list of types of the elements of the queue.
149 tuple_shapes: if not None, a list of shapes of the elements of the queue.
150 shard_dimensions: if not None, a list of dimensions on which the
151 elements of the queue should be sharded during automatic
152 parallelization.
153 name: the name of the queue.
154
155 Raises:
156 ValueError: if number_of_tuple_elements <= 0; or
157 number_of_tuple_arguments, tuple_types, tuple_shapes, and
158 shard_dimensions are all None; or the length of tuple_types,
159 tuple_shapes, or shard_dimensions is not equal to
160 number_of_tuple_elements; or any element of shard_dimensions
161 can&#x27;t be converted to a Dimension.
162 TypeError: if any element of tuple_types or tuple_shapes can&#x27;t
163 be converted to a dtype or TensorShape, respectively.
164 """
165 self._frozen = False
166 self._generated_enqueue_ops = False
167 self._generated_dequeue_op = False
168 self._name = "InfeedQueue" if name is None else name
169 if number_of_tuple_elements is None:
170 if tuple_types is not None:
171 number_of_tuple_elements = len(tuple_types)
172 elif tuple_shapes is not None:
173 number_of_tuple_elements = len(tuple_shapes)
174 elif shard_dimensions is not None:
175 number_of_tuple_elements = len(shard_dimensions)
176 else:
177 raise ValueError(
178 "number of tuple elements cannot be inferred from InfeedQueue "
179 "constructor")
180 if number_of_tuple_elements <= 0:
181 raise ValueError("number_of_tuple_elements %d must be > 0" %
182 number_of_tuple_elements)
183 # Make an empty sharding policy for each tuple element.
184 self._sharding_policies = [
185 tpu_sharding.ShardingPolicy()
186 for _ in xrange(number_of_tuple_elements)
187 ]
188 if tuple_types is not None:
189 self.set_tuple_types(tuple_types)
190 else:

Callers 1

__init__Method · 0.45

Calls 4

set_tuple_typesMethod · 0.95
set_tuple_shapesMethod · 0.95
set_shard_dimensionsMethod · 0.95
_validateMethod · 0.95

Tested by

no test coverage detected