def split(self, value, lengths, name=None): """Split the values of a `Tensor` into the TensorArray. Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional). Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations. """ with ops.colocate_with(self._handle): with ops.op_scope([self._handle, value, lengths], name, "TensorArraySplit"): lengths = math_ops.to_int64(lengths) flow_out = gen_data_flow_ops._tensor_array_split( handle=self._handle, value=value, lengths=lengths, flow_in=self._flow, name=name) ta = TensorArray(dtype=self._dtype, handle=self._handle) ta._flow = flow_out return ta
def split(self, value, lengths, name=None): """Split the values of a `Tensor` into the TensorArray.""" with ops.op_scope( [self._handle, value, lengths], name, "TensorArraySplit"): lengths = math_ops.to_int64(lengths) flow_out = gen_data_flow_ops._tensor_array_split( handle=self._handle, value=value, lengths=lengths, flow_in=self._flow, name=name) ta = TensorArray(dtype=self._dtype, handle=self._handle) ta._flow = flow_out return ta
def split(self, value, lengths, name=None): """Split the values of a `Tensor` into the TensorArray.""" with ops.op_scope([self._handle, value, lengths], name, "TensorArraySplit"): lengths = math_ops.to_int64(lengths) flow_out = gen_data_flow_ops._tensor_array_split(handle=self._handle, value=value, lengths=lengths, flow_in=self._flow, name=name) ta = TensorArray(dtype=self._dtype, handle=self._handle) ta._flow = flow_out return ta
def split(self, value, lengths, name=None): """Split the values of a `Tensor` into the TensorArray. Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional). Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations. Raises: ValueError: if the shape inference fails. """ with ops.colocate_with(self._handle): with ops.op_scope([self._handle, value, lengths], name, "TensorArraySplit"): lengths_64 = math_ops.to_int64(lengths) flow_out = gen_data_flow_ops._tensor_array_split( handle=self._handle, value=value, lengths=lengths_64, flow_in=self._flow, name=name) ta = TensorArray(dtype=self._dtype, handle=self._handle) ta._flow = flow_out ta._infer_shape = self._infer_shape ta._elem_shape = self._elem_shape if ta._infer_shape: val_shape = flow_out.op.inputs[1].get_shape() clengths = tensor_util.constant_value(flow_out.op.inputs[2]) elem_shape = tensor_shape.unknown_shape() if val_shape.dims: if clengths is not None and clengths.max() == clengths.min( ): elem_shape = tensor_shape.TensorShape( [clengths[0]] + val_shape.dims[1:]) if ta._elem_shape: if not elem_shape == ta._elem_shape[0]: raise ValueError( "Inconsistent shapes: saw %s but expected %s " "(and infer_shape=True)" % (elem_shape, ta._elem_shape[0])) else: ta._elem_shape.append(elem_shape) return ta
def split(self, value, lengths, name=None): """Split the values of a `Tensor` into the TensorArray. Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional). Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations. Raises: ValueError: if the shape inference fails. """ with ops.colocate_with(self._handle): with ops.name_scope(name, "TensorArraySplit", [self._handle, value, lengths]): lengths_64 = math_ops.to_int64(lengths) flow_out = gen_data_flow_ops._tensor_array_split( handle=self._handle, value=value, lengths=lengths_64, flow_in=self._flow, name=name) ta = TensorArray(dtype=self._dtype, handle=self._handle) ta._flow = flow_out ta._infer_shape = self._infer_shape ta._elem_shape = self._elem_shape if ta._infer_shape: val_shape = flow_out.op.inputs[1].get_shape() clengths = tensor_util.constant_value(flow_out.op.inputs[2]) elem_shape = tensor_shape.unknown_shape() if val_shape.dims is not None: if clengths is not None and clengths.max() == clengths.min(): elem_shape = tensor_shape.TensorShape( [clengths[0]] + val_shape.dims[1:]) if ta._elem_shape: if not elem_shape == ta._elem_shape[0]: raise ValueError( "Inconsistent shapes: saw %s but expected %s " "(and infer_shape=True)" % (elem_shape, ta._elem_shape[0])) else: ta._elem_shape.append(elem_shape) return ta
def split(self, value, lengths, name=None): """Split the values of a `Tensor` into the TensorArray. Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional). Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations. """ with ops.colocate_with(self._handle): with ops.op_scope([self._handle, value, lengths], name, "TensorArraySplit"): lengths = math_ops.to_int64(lengths) flow_out = gen_data_flow_ops._tensor_array_split( handle=self._handle, value=value, lengths=lengths, flow_in=self._flow, name=name ) ta = TensorArray(dtype=self._dtype, handle=self._handle) ta._flow = flow_out return ta