diff --git a/RawOpsGenerated.swift b/RawOpsGenerated.swift index 86501fe..8c95eb8 100644 --- a/RawOpsGenerated.swift +++ b/RawOpsGenerated.swift @@ -1582,6 +1582,71 @@ public static func b( return Tensor(handle: ret) } +/// Batches all input tensors nondeterministically. +/// +/// When many instances of this Op are being run concurrently with the same +/// container/shared_name in the same device, some will output zero-shaped Tensors +/// and others will output Tensors of size up to max_batch_size. +/// +/// All Tensors in in_tensors are batched together (so, for example, labels and +/// features should be batched with a single instance of this operation. +/// +/// Each invocation of batch emits an `id` scalar which will be used to identify +/// this particular invocation when doing unbatch or its gradient. +/// +/// Each op which emits a non-empty batch will also emit a non-empty batch_index +/// Tensor, which, is a [K, 3] matrix where each row contains the invocation's id, +/// start, and length of elements of each set of Tensors present in batched_tensors. +/// +/// Batched tensors are concatenated along the first dimension, and all tensors in +/// in_tensors must have the first dimension of the same size. +/// +/// in_tensors: The tensors to be batched. +/// num_batch_threads: Number of scheduling threads for processing batches of work. +/// Determines the number of batches processed in parallel. +/// max_batch_size: Batch sizes will never be bigger than this. +/// batch_timeout_micros: Maximum number of microseconds to wait before outputting +/// an incomplete batch. +/// allowed_batch_sizes: Optional list of allowed batch sizes. If left empty, does +/// nothing. Otherwise, supplies a list of batch sizes, causing the op to pad +/// batches up to one of those sizes. The entries must increase monotonically, and +/// the final entry must equal max_batch_size. +/// grad_timeout_micros: The timeout to use for the gradient. See Unbatch. +/// batched_tensors: Either empty tensors or a batch of concatenated Tensors. +/// batch_index: If out_tensors is non-empty, has information to invert it. +/// container: Controls the scope of sharing of this batch. +/// id: always contains a scalar with a unique ID for this invocation of Batch. +/// shared_name: Concurrently running instances of batch in the same device with the +/// same container and shared_name will batch their elements together. If left +/// empty, the op name will be used as the shared name. +/// T: the types of tensors to be batched. +@inlinable @inline(__always) +public static func batch( + inTensors: [Tensor], + numBatchThreads: Int64, + maxBatchSize: Int64, + maxEnqueuedBatches: Int64 = 10, + batchTimeoutMicros: Int64, + allowedBatchSizes: [Int32], + gradTimeoutMicros: Int64, + container: String, + sharedName: String, + batchingQueue: String +) -> (batchedTensors: [Tensor], batchIndex: Tensor, id: Tensor) { + let ret: ([TensorHandle], TensorHandle, TensorHandle) = #tfop("Batch", + inTensors, + num_batch_threads: numBatchThreads, + max_batch_size: maxBatchSize, + max_enqueued_batches: maxEnqueuedBatches, + batch_timeout_micros: batchTimeoutMicros, + allowed_batch_sizes: allowedBatchSizes, + grad_timeout_micros: gradTimeoutMicros, + container: container, + shared_name: sharedName, + batching_queue: batchingQueue) + return (Tensor(handle: ret.0), Tensor(handle: ret.1), Tensor(handle: ret.2)) +} + @inlinable @inline(__always) public static func batchCholesky( _ input: Tensor @@ -2609,6 +2674,108 @@ public static func blockLSTMGrad( return (Tensor(handle: ret.0), Tensor(handle: ret.1), Tensor(handle: ret.2), Tensor(handle: ret.3), Tensor(handle: ret.4), Tensor(handle: ret.5), Tensor(handle: ret.6), Tensor(handle: ret.7)) } +/// Bucketize each feature based on bucket boundaries. +/// +/// An op that returns a list of float tensors, where each tensor represents the +/// bucketized values for a single feature. +/// +/// - Parameters: +/// - float_values: float; List of Rank 1 Tensor each containing float values for a single feature. +/// - bucket_boundaries: float; List of Rank 1 Tensors each containing the bucket boundaries for a single +/// feature. +/// +/// - Attr num_features: inferred int; number of features. +/// +/// - Output buckets: int; List of Rank 1 Tensors each containing the bucketized values for a single feature. +@inlinable @inline(__always) +public static func boostedTreesBucketize( + floatValues: [Tensor], + bucketBoundaries: [Tensor] +) -> [Tensor] { + let ret: [TensorHandle] = #tfop("BoostedTreesBucketize", + floatValues, + bucketBoundaries) + return Tensor(handle: ret) +} + +/// Calculates gains for each feature and returns the best possible split information for the feature. +/// +/// The split information is the best threshold (bucket id), gains and left/right node contributions per node for each feature. +/// +/// It is possible that not all nodes can be split on each feature. Hence, the list of possible nodes can differ between the features. Therefore, we return `node_ids_list` for each feature, containing the list of nodes that this feature can be used to split. +/// +/// In this manner, the output is the best split per features and per node, so that it needs to be combined later to produce the best split for each node (among all possible features). +/// +/// The length of output lists are all of the same length, `num_features`. +/// The output shapes are compatible in a way that the first dimension of all tensors of all lists are the same and equal to the number of possible split nodes for each feature. +/// +/// - Parameters: +/// - node_id_range: A Rank 1 tensor (shape=[2]) to specify the range [first, last) of node ids to process within `stats_summary_list`. The nodes are iterated between the two nodes specified by the tensor, as like `for node_id in range(node_id_range[0], node_id_range[1])` (Note that the last index node_id_range[1] is exclusive). +/// - stats_summary_list: A list of Rank 3 tensor (#shape=[max_splits, bucket, 2]) for accumulated stats summary (gradient/hessian) per node per buckets for each feature. The first dimension of the tensor is the maximum number of splits, and thus not all elements of it will be used, but only the indexes specified by node_ids will be used. +/// - l1: l1 regularization factor on leaf weights, per instance based. +/// - l2: l2 regularization factor on leaf weights, per instance based. +/// - tree_complexity: adjustment to the gain, per leaf based. +/// - min_node_weight: mininum avg of hessians in a node before required for the node to be considered for splitting. +/// +/// - Attrs: +/// - max_splits: the number of nodes that can be split in the whole tree. Used as a dimension of output tensors. +/// - num_features: inferred from the size of `stats_summary_list`; the number of total features. +/// +/// - Outputs: +/// - node_ids_list: An output list of Rank 1 tensors indicating possible split node ids for each feature. The length of the list is num_features, but each tensor has different size as each feature provides different possible nodes. See above for details like shapes and sizes. +/// - gains_list: An output list of Rank 1 tensors indicating the best gains for each feature to split for certain nodes. See above for details like shapes and sizes. +/// - thresholds_list: An output list of Rank 1 tensors indicating the bucket id to compare with (as a threshold) for split in each node. See above for details like shapes and sizes. +/// - left_node_contribs_list: A list of Rank 2 tensors indicating the contribution of the left nodes when branching from parent nodes (given by the tensor element in the output node_ids_list) to the left direction by the given threshold for each feature. This value will be used to make the left node value by adding to the parent node value. Second dimension size is 1 for 1-dimensional logits, but would be larger for multi-class problems. See above for details like shapes and sizes. +/// - right_node_contribs_list: A list of Rank 2 tensors, with the same shape/conditions as left_node_contribs_list, but just that the value is for the right node. +@inlinable @inline(__always) +public static func boostedTreesCalculateBestGainsPerFeature( + nodeIdRange: Tensor, + statsSummaryList: [Tensor], + l1: Tensor, + l2: Tensor, + treeComplexity: Tensor, + minNodeWeight: Tensor, + maxSplits: Int64 +) -> (nodeIdsList: [Tensor], gainsList: [Tensor], thresholdsList: [Tensor], leftNodeContribsList: [Tensor], rightNodeContribsList: [Tensor]) { + let ret: ([TensorHandle], [TensorHandle], [TensorHandle], [TensorHandle], [TensorHandle]) = #tfop("BoostedTreesCalculateBestGainsPerFeature", + nodeIdRange, + statsSummaryList, + l1, + l2, + treeComplexity, + minNodeWeight, + max_splits: maxSplits) + return (Tensor(handle: ret.0), Tensor(handle: ret.1), Tensor(handle: ret.2), Tensor(handle: ret.3), Tensor(handle: ret.4)) +} + +/// Makes the summary of quantiles for the batch. +/// +/// An op that takes a list of tensors (one tensor per feature) and outputs the +/// quantile summaries for each tensor. +/// +/// - Parameters: +/// - float_values: float; List of Rank 1 Tensors each containing values for a single feature. +/// - example_weights: float; Rank 1 Tensor with weights per instance. +/// - epsilon: float; The required maximum approximation error. +/// +/// - Attr num_features: int; Inferred from the size of float_values. +/// The number of float features. +/// +/// - Output summaries: float; List of Rank 2 Tensors each containing the quantile summary +/// (value, weight, min_rank, max_rank) of a single feature. +@inlinable @inline(__always) +public static func boostedTreesMakeQuantileSummaries( + floatValues: [Tensor], + exampleWeights: Tensor, + epsilon: Tensor +) -> [Tensor] { + let ret: [TensorHandle] = #tfop("BoostedTreesMakeQuantileSummaries", + floatValues, + exampleWeights, + epsilon) + return Tensor(handle: ret) +} + /// Makes the summary of accumulated stats for the batch. /// /// The summary stats contains gradients and hessians accumulated into the corresponding node and bucket for each example. @@ -2747,6 +2914,52 @@ public static func bucketize( return Tensor(handle: ret) } +/// Performs beam search decoding on the logits given in input. +/// +/// A note about the attribute merge_repeated: For the beam search decoder, +/// this means that if consecutive entries in a beam are the same, only +/// the first of these is emitted. That is, when the top path is "A B B B B", +/// "A B" is returned if merge_repeated = True but "A B B B B" is +/// returned if merge_repeated = False. +/// +/// - Parameters: +/// - inputs: 3-D, shape: `(max_time x batch_size x num_classes)`, the logits. +/// - sequence_length: A vector containing sequence lengths, size `(batch)`. +/// +/// - Attrs: +/// - beam_width: A scalar >= 0 (beam search beam width). +/// - top_paths: A scalar >= 0, <= beam_width (controls output size). +/// - merge_repeated: If true, merge repeated classes in output. +/// +/// - Outputs: +/// - decoded_indices: A list (length: top_paths) of indices matrices. Matrix j, +/// size `(total_decoded_outputs[j] x 2)`, has indices of a +/// `SparseTensor`. The rows store: [batch, time]. +/// - decoded_values: A list (length: top_paths) of values vectors. Vector j, +/// size `(length total_decoded_outputs[j])`, has the values of a +/// `SparseTensor`. The vector stores the decoded classes for beam j. +/// - decoded_shape: A list (length: top_paths) of shape vector. Vector j, +/// size `(2)`, stores the shape of the decoded `SparseTensor[j]`. +/// Its values are: `[batch_size, max_decoded_length[j]]`. +/// - log_probability: A matrix, shaped: `(batch_size x top_paths)`. The +/// sequence log-probabilities. +@inlinable @inline(__always) +public static func cTCBeamSearchDecoder( + inputs: Tensor, + sequenceLength: Tensor, + beamWidth: Int64, + topPaths: Int64, + mergeRepeated: Bool = true +) -> (decodedIndices: [Tensor], decodedValues: [Tensor], decodedShape: [Tensor], logProbability: Tensor) { + let ret: ([TensorHandle], [TensorHandle], [TensorHandle], TensorHandle) = #tfop("CTCBeamSearchDecoder", + inputs, + sequenceLength, + beam_width: beamWidth, + top_paths: topPaths, + merge_repeated: mergeRepeated) + return (Tensor(handle: ret.0), Tensor(handle: ret.1), Tensor(handle: ret.2), Tensor(handle: ret.3)) +} + /// Performs greedy decoding on the logits given in inputs. /// /// A note about the attribute merge_repeated: if enabled, when @@ -3174,6 +3387,17 @@ public static func complexAbs( + nA: Int64, + nB: Int64 +) -> (a: [Tensor], b: [Tensor], c: [Tensor]) { + let ret: ([TensorHandle], [TensorHandle], [TensorHandle]) = #tfop("ComplexStruct", + n_a: nA, + n_b: nB) + return (Tensor(handle: ret.0), Tensor(handle: ret.1), Tensor(handle: ret.2)) +} + /// Computes the ids of the positions in sampled_candidates that match true_labels. /// /// When doing log-odds NCE, the result of this op should be passed through a @@ -3238,6 +3462,36 @@ public static func concat( return Tensor(handle: ret) } +/// Computes offsets of concat inputs within its output. +/// +/// For example: +/// +/// ``` +/// # 'x' is [2, 2, 7] +/// # 'y' is [2, 3, 7] +/// # 'z' is [2, 5, 7] +/// concat_offset(2, [x, y, z]) => [0, 0, 0], [0, 2, 0], [0, 5, 0] +/// ``` +/// +/// This is typically used by gradient computations for a concat operation. +/// +/// - Parameters: +/// - concat_dim: The dimension along which to concatenate. +/// - shape: The `N` int32 vectors representing shape of tensors being concatenated. +/// +/// - Output offset: The `N` int32 vectors representing the starting offset +/// of input tensors within the concatenated output. +@inlinable @inline(__always) +public static func concatOffset( + concatDim: Tensor, + shape: [Tensor] +) -> [Tensor] { + let ret: [TensorHandle] = #tfop("ConcatOffset", + concatDim, + shape) + return Tensor(handle: ret) +} + /// Concatenates tensors along one dimension. /// /// - Parameters: @@ -4489,6 +4743,67 @@ public static func cudnnRNNParamsSize