diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/AudioOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/AudioOps.java index 16770394378..ca9f4fe8443 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/AudioOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/AudioOps.java @@ -34,8 +34,11 @@ public final class AudioOps { private final Scope scope; - AudioOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + AudioOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -144,4 +147,11 @@ public Mfcc mfcc(Operand spectrogram, Operand sampleRate, Mfcc.Options... options) { return Mfcc.create(scope, spectrogram, sampleRate, options); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/BitwiseOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/BitwiseOps.java index 8ac6d565e51..c023586f94e 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/BitwiseOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/BitwiseOps.java @@ -34,8 +34,11 @@ public final class BitwiseOps { private final Scope scope; - BitwiseOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + BitwiseOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -268,4 +271,11 @@ public LeftShift leftShift(Operand x, Operand y) { public RightShift rightShift(Operand x, Operand y) { return RightShift.create(scope, x, y); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DataExperimentalOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DataExperimentalOps.java index cccc4ac8dcb..f78720827b0 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DataExperimentalOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DataExperimentalOps.java @@ -33,8 +33,11 @@ public final class DataExperimentalOps { private final Scope scope; - DataExperimentalOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + DataExperimentalOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -58,4 +61,11 @@ public DataServiceDataset dataServiceDataset(Operand datasetId, DataServiceDataset.Options... options) { return DataServiceDataset.create(scope, datasetId, processingMode, address, protocol, jobName, maxOutstandingRequests, iterationCounter, outputTypes, outputShapes, options); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DataOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DataOps.java index 273025ef6bd..b3207a5d4e7 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DataOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DataOps.java @@ -60,9 +60,12 @@ public final class DataOps { private final Scope scope; - DataOps(Scope scope) { - this.scope = scope; - experimental = new DataExperimentalOps(scope); + private final Ops ops; + + DataOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; + experimental = new DataExperimentalOps(ops); } /** @@ -410,4 +413,11 @@ public ZipDataset zipDataset(Iterable> inputDatasets, List outputShapes) { return ZipDataset.create(scope, inputDatasets, outputTypes, outputShapes); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DtypesOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DtypesOps.java index 16d571a6428..1fb69c6637d 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DtypesOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DtypesOps.java @@ -33,8 +33,11 @@ public final class DtypesOps { private final Scope scope; - DtypesOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + DtypesOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -102,4 +105,11 @@ public Complex complex(Operand real, DataType Tout) { return Complex.create(scope, real, imag, Tout); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/ImageOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/ImageOps.java index eea2fc4b8f1..35791f74ec8 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/ImageOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/ImageOps.java @@ -66,8 +66,11 @@ public final class ImageOps { private final Scope scope; - ImageOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + ImageOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -942,4 +945,11 @@ public ScaleAndTranslate scaleAndTranslate(Operand images ScaleAndTranslate.Options... options) { return ScaleAndTranslate.create(scope, images, size, scale, translation, options); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/IoOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/IoOps.java index adc656dc5af..3cb7569ab38 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/IoOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/IoOps.java @@ -82,8 +82,11 @@ public final class IoOps { private final Scope scope; - IoOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + IoOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -1030,4 +1033,11 @@ public WholeFileReader wholeFileReader(WholeFileReader.Options... options) { public WriteFile writeFile(Operand filename, Operand contents) { return WriteFile.create(scope, filename, contents); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/LinalgOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/LinalgOps.java index b2242f1068e..6d63d9ddd89 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/LinalgOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/LinalgOps.java @@ -78,8 +78,11 @@ public final class LinalgOps { private final Scope scope; - LinalgOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + LinalgOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -1606,4 +1609,11 @@ public TriangularSolve triangularSolve(Operand matrix, O TriangularSolve.Options... options) { return TriangularSolve.create(scope, matrix, rhs, options); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/LinalgSparseOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/LinalgSparseOps.java deleted file mode 100644 index 7f8777c883a..00000000000 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/LinalgSparseOps.java +++ /dev/null @@ -1,463 +0,0 @@ -// Copyright 2020 The TensorFlow Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================== -// -// This class has been generated, DO NOT EDIT! -// -package org.tensorflow.op; - -import org.tensorflow.DataType; -import org.tensorflow.Operand; -import org.tensorflow.op.linalg.sparse.CSRSparseMatrixToSparseTensor; -import org.tensorflow.op.linalg.sparse.DenseToCSRSparseMatrix; -import org.tensorflow.op.linalg.sparse.SparseMatrixAdd; -import org.tensorflow.op.linalg.sparse.SparseMatrixMatMul; -import org.tensorflow.op.linalg.sparse.SparseMatrixMul; -import org.tensorflow.op.linalg.sparse.SparseMatrixNNZ; -import org.tensorflow.op.linalg.sparse.SparseMatrixOrderingAMD; -import org.tensorflow.op.linalg.sparse.SparseMatrixSoftmax; -import org.tensorflow.op.linalg.sparse.SparseMatrixSoftmaxGrad; -import org.tensorflow.op.linalg.sparse.SparseMatrixSparseCholesky; -import org.tensorflow.op.linalg.sparse.SparseMatrixSparseMatMul; -import org.tensorflow.op.linalg.sparse.SparseMatrixTranspose; -import org.tensorflow.op.linalg.sparse.SparseMatrixZeros; -import org.tensorflow.op.linalg.sparse.SparseTensorToCSRSparseMatrix; -import org.tensorflow.types.TInt32; -import org.tensorflow.types.TInt64; -import org.tensorflow.types.family.TNumber; -import org.tensorflow.types.family.TType; - -/** - * An API for building {@code linalg.sparse} operations as {@link Op Op}s - * - * @see {@link Ops} - */ -public final class LinalgSparseOps { - private final Scope scope; - - LinalgSparseOps(Scope scope) { - this.scope = scope; - } - - /** - * Converts a (possibly batched) CSRSparesMatrix to a SparseTensor. - * - * @param data type for {@code values()} output - * @param sparseMatrix A (possibly batched) CSRSparseMatrix. - * @param type - * @return a new instance of CSRSparseMatrixToSparseTensor - */ - public CSRSparseMatrixToSparseTensor cSRSparseMatrixToSparseTensor( - Operand sparseMatrix, DataType type) { - return CSRSparseMatrixToSparseTensor.create(scope, sparseMatrix, type); - } - - /** - * Converts a dense tensor to a (possibly batched) CSRSparseMatrix. - * - * @param denseInput A Dense tensor. - * @param indices Indices of nonzero elements. - * @return a new instance of DenseToCSRSparseMatrix - */ - public DenseToCSRSparseMatrix denseToCSRSparseMatrix(Operand denseInput, - Operand indices) { - return DenseToCSRSparseMatrix.create(scope, denseInput, indices); - } - - /** - * Sparse addition of two CSR matrices, C = alpha * A + beta * B. - *

- * The gradients of SparseMatrixAdd outputs with respect to alpha and beta are not - * currently defined (TensorFlow will return zeros for these entries). - * - * @param a A CSRSparseMatrix. - * @param b A CSRSparseMatrix. - * @param alpha A constant scalar. - * @param beta A constant scalar. - * @return a new instance of SparseMatrixAdd - */ - public SparseMatrixAdd sparseMatrixAdd(Operand a, Operand b, - Operand alpha, Operand beta) { - return SparseMatrixAdd.create(scope, a, b, alpha, beta); - } - - /** - * Matrix-multiplies a sparse matrix with a dense matrix. - *

- * Returns a dense matrix. - * For inputs A and B, where A is CSR and B is dense; this op returns a dense C; - *

- * If transpose_output is false, returns: - *

{@code
-   *    C = A . B
-   *  }
- * If transpose_output is `true`, returns: - *
{@code
-   *    C = transpose(A . B) = transpose(B) . transpose(A)
-   *  }
- * where the transposition is performed along the two innermost (matrix) - * dimensions. - *

- * If conjugate_output is `true`, returns: - *

{@code
-   *    C = conjugate(A . B) = conjugate(A) . conjugate(B)
-   *  }
- * If both conjugate_output and transpose_output are `true`, returns: - *
{@code
-   *    C = conjugate(transpose(A . B)) = conjugate(transpose(B)) .
-   *                                      conjugate(transpose(A))
-   *  }
- * - * @param data type for {@code output()} output - * @param a A CSRSparseMatrix. - * @param b A dense tensor. - * @param options carries optional attributes values - * @return a new instance of SparseMatrixMatMul - */ - public SparseMatrixMatMul sparseMatrixMatMul(Operand a, Operand b, - SparseMatrixMatMul.Options... options) { - return SparseMatrixMatMul.create(scope, a, b, options); - } - - /** - * Element-wise multiplication of a sparse matrix with a dense tensor. - *

- * Returns a sparse matrix. - *

- * The dense tensor `b` may be either a scalar; otherwise `a` must be a rank-3 - * `SparseMatrix`; in this case `b` must be shaped `[batch_size, 1, 1]` and the - * multiply operation broadcasts. - *

- * NOTE even if `b` is zero, the sparsity structure of the output does not - * change. - * - * @param a A CSRSparseMatrix. - * @param b A dense tensor. - * @return a new instance of SparseMatrixMul - */ - public SparseMatrixMul sparseMatrixMul(Operand a, Operand b) { - return SparseMatrixMul.create(scope, a, b); - } - - /** - * Returns the number of nonzeroes of `sparse_matrix`. - * - * @param sparseMatrix A CSRSparseMatrix. - * @return a new instance of SparseMatrixNNZ - */ - public SparseMatrixNNZ sparseMatrixNNZ(Operand sparseMatrix) { - return SparseMatrixNNZ.create(scope, sparseMatrix); - } - - /** - * Computes the Approximate Minimum Degree (AMD) ordering of `input`. - *

- * Computes the Approximate Minimum Degree (AMD) ordering for a sparse matrix. - *

- * The returned permutation may be used to permute the rows and columns of the - * given sparse matrix. This typically results in permuted sparse matrix's sparse - * Cholesky (or other decompositions) in having fewer zero fill-in compared to - * decomposition of the original matrix. - *

- * The input sparse matrix may have rank 2 or rank 3. The output Tensor, - * representing would then have rank 1 or 2 respectively, with the same batch - * shape as the input. - *

- * Each component of the input sparse matrix must represent a square symmetric - * matrix; only the lower triangular part of the matrix is read. The values of the - * sparse matrix does not affect the returned permutation, only the sparsity - * pattern of the sparse matrix is used. Hence, a single AMD ordering may be - * reused for the Cholesky decompositions of sparse matrices with the same sparsity - * pattern but with possibly different values. - *

- * Each batch component of the output permutation represents a permutation of `N` - * elements, where the input sparse matrix components each have `N` rows. That is, - * the component contains each of the integers `{0, .. N-1}` exactly once. The - * `i`th element represents the row index that the `i`th row maps to. - *

- * Usage example: - *

{@code
-   *      from tensorflow.python.ops.linalg.sparse import sparse_csr_matrix_ops
-   *
-   *      a_indices = np.array([[0, 0], [1, 1], [2, 1], [2, 2], [3, 3]])
-   *      a_values = np.array([1.0, 2.0, 1.0, 3.0, 4.0], np.float32)
-   *      a_dense_shape = [4, 4]
-   *
-   *      with tf.Session() as sess:
-   *        # Define (COO format) SparseTensor over Numpy array.
-   *        a_st = tf.SparseTensor(a_indices, a_values, a_dense_shape)
-   *
-   *        # Convert SparseTensors to CSR SparseMatrix.
-   *        a_sm = sparse_csr_matrix_ops.sparse_tensor_to_csr_sparse_matrix(
-   *            a_st.indices, a_st.values, a_st.dense_shape)
-   *
-   *        # Obtain the AMD Ordering for the CSR SparseMatrix.
-   *        ordering_amd = sparse_csr_matrix_ops.sparse_matrix_ordering_amd(sparse_matrix)
-   *
-   *        ordering_amd_value = sess.run(ordering_amd)
-   *  }
- * `ordering_amd_value` stores the AMD ordering: `[1 2 3 0]`. - *

- * input: A `CSRSparseMatrix`. - * - * @param input A `CSRSparseMatrix`. - * @return a new instance of SparseMatrixOrderingAMD - */ - public SparseMatrixOrderingAMD sparseMatrixOrderingAMD(Operand input) { - return SparseMatrixOrderingAMD.create(scope, input); - } - - /** - * Calculates the softmax of a CSRSparseMatrix. - *

- * Calculate the softmax of the innermost dimensions of a SparseMatrix. - *

- * Missing values are treated as `-inf` (i.e., logits of zero probability); and - * the output has the same sparsity structure as the input (though missing values - * in the output may now be treated as having probability zero). - * - * @param logits A CSRSparseMatrix. - * @param type - * @return a new instance of SparseMatrixSoftmax - */ - public SparseMatrixSoftmax sparseMatrixSoftmax(Operand logits, - DataType type) { - return SparseMatrixSoftmax.create(scope, logits, type); - } - - /** - * Calculates the gradient of the SparseMatrixSoftmax op. - * - * @param softmax A CSRSparseMatrix. - * @param gradSoftmax The gradient of `softmax`. - * @param type - * @return a new instance of SparseMatrixSoftmaxGrad - */ - public SparseMatrixSoftmaxGrad sparseMatrixSoftmaxGrad(Operand softmax, - Operand gradSoftmax, DataType type) { - return SparseMatrixSoftmaxGrad.create(scope, softmax, gradSoftmax, type); - } - - /** - * Computes the sparse Cholesky decomposition of `input`. - *

- * Computes the Sparse Cholesky decomposition of a sparse matrix, with the given - * fill-in reducing permutation. - *

- * The input sparse matrix and the fill-in reducing permutation `permutation` must - * have compatible shapes. If the sparse matrix has rank 3; with the batch - * dimension `B`, then the `permutation` must be of rank 2; with the same batch - * dimension `B`. There is no support for broadcasting. - *

- * Furthermore, each component vector of `permutation` must be of length `N`, - * containing each of the integers {0, 1, ..., N - 1} exactly once, where `N` is - * the number of rows of each component of the sparse matrix. - *

- * Each component of the input sparse matrix must represent a symmetric positive - * definite (SPD) matrix; although only the lower triangular part of the matrix is - * read. If any individual component is not SPD, then an InvalidArgument error is - * thrown. - *

- * The returned sparse matrix has the same dense shape as the input sparse matrix. - * For each component `A` of the input sparse matrix, the corresponding output - * sparse matrix represents `L`, the lower triangular Cholesky factor satisfying - * the following identity: - *

{@code
-   *    A = L * Lt
-   *  }
- * where Lt denotes the transpose of L (or its conjugate transpose, if `type` is - * `complex64` or `complex128`). - *

- * The `type` parameter denotes the type of the matrix elements. The supported - * types are: `float32`, `float64`, `complex64` and `complex128`. - *

- * Usage example: - *

{@code
-   *      from tensorflow.python.ops.linalg.sparse import sparse_csr_matrix_ops
-   *
-   *      a_indices = np.array([[0, 0], [1, 1], [2, 1], [2, 2], [3, 3]])
-   *      a_values = np.array([1.0, 2.0, 1.0, 3.0, 4.0], np.float32)
-   *      a_dense_shape = [4, 4]
-   *
-   *      with tf.Session() as sess:
-   *        # Define (COO format) SparseTensor over Numpy array.
-   *        a_st = tf.SparseTensor(a_indices, a_values, a_dense_shape)
-   *
-   *        # Convert SparseTensors to CSR SparseMatrix.
-   *        a_sm = sparse_csr_matrix_ops.sparse_tensor_to_csr_sparse_matrix(
-   *            a_st.indices, a_st.values, a_st.dense_shape)
-   *
-   *        # Obtain the Sparse Cholesky factor using AMD Ordering for reducing zero
-   *        # fill-in (number of structural non-zeros in the sparse Cholesky factor).
-   *        ordering_amd = sparse_csr_matrix_ops.sparse_matrix_ordering_amd(sparse_matrix)
-   *        cholesky_sparse_matrices = (
-   *            sparse_csr_matrix_ops.sparse_matrix_sparse_cholesky(
-   *                sparse_matrix, ordering_amd, type=tf.float32))
-   *
-   *        # Convert the CSRSparseMatrix Cholesky factor to a dense Tensor
-   *        dense_cholesky = sparse_csr_matrix_ops.csr_sparse_matrix_to_dense(
-   *            cholesky_sparse_matrices, tf.float32)
-   *
-   *        # Evaluate the dense Tensor value.
-   *        dense_cholesky_value = sess.run(dense_cholesky)
-   *  }
- * `dense_cholesky_value` stores the dense Cholesky factor: - *
{@code
-   *      [[  1.  0.    0.    0.]
-   *       [  0.  1.41  0.    0.]
-   *       [  0.  0.70  1.58  0.]
-   *       [  0.  0.    0.    2.]]
-   *  }
- * input: A `CSRSparseMatrix`. - * permutation: A `Tensor`. - * type: The type of `input`. - * - * @param input A `CSRSparseMatrix`. - * @param permutation A fill-in reducing permutation matrix. - * @param type - * @return a new instance of SparseMatrixSparseCholesky - */ - public SparseMatrixSparseCholesky sparseMatrixSparseCholesky(Operand input, - Operand permutation, DataType type) { - return SparseMatrixSparseCholesky.create(scope, input, permutation, type); - } - - /** - * Sparse-matrix-multiplies two CSR matrices `a` and `b`. - *

- * Performs a matrix multiplication of a sparse matrix `a` with a sparse matrix - * `b`; returns a sparse matrix `a * b`, unless either `a` or `b` is transposed or - * adjointed. - *

- * Each matrix may be transposed or adjointed (conjugated and transposed) - * according to the Boolean parameters `transpose_a`, `adjoint_a`, `transpose_b` - * and `adjoint_b`. At most one of `transpose_a` or `adjoint_a` may be True. - * Similarly, at most one of `transpose_b` or `adjoint_b` may be True. - *

- * The inputs must have compatible shapes. That is, the inner dimension of `a` - * must be equal to the outer dimension of `b`. This requirement is adjusted - * according to whether either `a` or `b` is transposed or adjointed. - *

- * The `type` parameter denotes the type of the matrix elements. Both `a` and `b` - * must have the same type. The supported types are: `float32`, `float64`, - * `complex64` and `complex128`. - *

- * Both `a` and `b` must have the same rank. Broadcasting is not supported. If they - * have rank 3, each batch of 2D CSRSparseMatrices within `a` and `b` must have the - * same dense shape. - *

- * The sparse matrix product may have numeric (non-structural) zeros. - * TODO(anudhyan): Consider adding a boolean attribute to control whether to prune - * zeros. - *

- * Usage example: - *

{@code
-   *      from tensorflow.python.ops.linalg.sparse import sparse_csr_matrix_ops
-   *
-   *      a_indices = np.array([[0, 0], [2, 3], [2, 4], [3, 0]])
-   *      a_values = np.array([1.0, 5.0, -1.0, -2.0], np.float32)
-   *      a_dense_shape = [4, 5]
-   *
-   *      b_indices = np.array([[0, 0], [3, 0], [3, 1]])
-   *      b_values = np.array([2.0, 7.0, 8.0], np.float32)
-   *      b_dense_shape = [5, 3]
-   *
-   *      with tf.Session() as sess:
-   *        # Define (COO format) Sparse Tensors over Numpy arrays
-   *        a_st = tf.SparseTensor(a_indices, a_values, a_dense_shape)
-   *        b_st = tf.SparseTensor(b_indices, b_values, b_dense_shape)
-   *
-   *        # Convert SparseTensors to CSR SparseMatrix
-   *        a_sm = sparse_csr_matrix_ops.sparse_tensor_to_csr_sparse_matrix(
-   *            a_st.indices, a_st.values, a_st.dense_shape)
-   *        b_sm = sparse_csr_matrix_ops.sparse_tensor_to_csr_sparse_matrix(
-   *            b_st.indices, b_st.values, b_st.dense_shape)
-   *
-   *        # Compute the CSR SparseMatrix matrix multiplication
-   *        c_sm = sparse_csr_matrix_ops.sparse_matrix_sparse_mat_mul(
-   *            a=a_sm, b=b_sm, type=tf.float32)
-   *
-   *        # Convert the CSR SparseMatrix product to a dense Tensor
-   *        c_sm_dense = sparse_csr_matrix_ops.csr_sparse_matrix_to_dense(
-   *            c_sm, tf.float32)
-   *        # Evaluate the dense Tensor value
-   *        c_sm_dense_value = sess.run(c_sm_dense)
-   *  }
- * `c_sm_dense_value` stores the dense matrix product: - *
{@code
-   *      [[  2.   0.   0.]
-   *       [  0.   0.   0.]
-   *       [ 35.  40.   0.]
-   *       [ -4.   0.   0.]]
-   *  }
- * a: A `CSRSparseMatrix`. - * b: A `CSRSparseMatrix` with the same type and rank as `a`. - * type: The type of both `a` and `b`. - * transpose_a: If True, `a` transposed before multiplication. - * transpose_b: If True, `b` transposed before multiplication. - * adjoint_a: If True, `a` adjointed before multiplication. - * adjoint_b: If True, `b` adjointed before multiplication. - * - * @param a A CSRSparseMatrix. - * @param b A CSRSparseMatrix. - * @param type - * @param options carries optional attributes values - * @return a new instance of SparseMatrixSparseMatMul - */ - public SparseMatrixSparseMatMul sparseMatrixSparseMatMul(Operand a, - Operand b, DataType type, SparseMatrixSparseMatMul.Options... options) { - return SparseMatrixSparseMatMul.create(scope, a, b, type, options); - } - - /** - * Transposes the inner (matrix) dimensions of a CSRSparseMatrix. - *

- * Transposes the inner (matrix) dimensions of a SparseMatrix and optionally - * conjugates its values. - * - * @param input A CSRSparseMatrix. - * @param type - * @param options carries optional attributes values - * @return a new instance of SparseMatrixTranspose - */ - public SparseMatrixTranspose sparseMatrixTranspose(Operand input, - DataType type, SparseMatrixTranspose.Options... options) { - return SparseMatrixTranspose.create(scope, input, type, options); - } - - /** - * Creates an all-zeros CSRSparseMatrix with shape `dense_shape`. - * - * @param denseShape The desired matrix shape. - * @param type - * @return a new instance of SparseMatrixZeros - */ - public SparseMatrixZeros sparseMatrixZeros(Operand denseShape, - DataType type) { - return SparseMatrixZeros.create(scope, denseShape, type); - } - - /** - * Converts a SparseTensor to a (possibly batched) CSRSparseMatrix. - * - * @param indices SparseTensor indices. - * @param values SparseTensor values. - * @param denseShape SparseTensor dense shape. - * @return a new instance of SparseTensorToCSRSparseMatrix - */ - public SparseTensorToCSRSparseMatrix sparseTensorToCSRSparseMatrix( - Operand indices, Operand values, Operand denseShape) { - return SparseTensorToCSRSparseMatrix.create(scope, indices, values, denseShape); - } -} diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/MathOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/MathOps.java index 1f08502ca44..b193c2e404d 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/MathOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/MathOps.java @@ -138,8 +138,11 @@ public final class MathOps { private final Scope scope; - MathOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + MathOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -2391,4 +2394,11 @@ public Xlogy xlogy(Operand x, Operand y) { public Zeta zeta(Operand x, Operand q) { return Zeta.create(scope, x, q); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/NnOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/NnOps.java index 81a24514a08..0992cc606ba 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/NnOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/NnOps.java @@ -108,9 +108,12 @@ public final class NnOps { private final Scope scope; - NnOps(Scope scope) { - this.scope = scope; - raw = new NnRawOps(scope); + private final Ops ops; + + NnOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; + raw = new NnRawOps(ops); } /** @@ -2148,4 +2151,11 @@ public TopK topK(Operand input, Operand k, TopK.Options... options) { return TopK.create(scope, input, k, options); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/NnRawOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/NnRawOps.java index d9147af3934..64cecadbe6d 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/NnRawOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/NnRawOps.java @@ -30,8 +30,11 @@ public final class NnRawOps { private final Scope scope; - NnRawOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + NnRawOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -71,4 +74,11 @@ public SparseSoftmaxCrossEntropyWithLogit Operand features, Operand labels) { return SparseSoftmaxCrossEntropyWithLogits.create(scope, features, labels); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java index 8c7aa1c0408..9a529e86eb4 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java @@ -347,33 +347,33 @@ public final class Ops { public final SignalOps signal; - public final QuantizationOps quantization; - public final TrainOps train; + public final QuantizationOps quantization; + private final Scope scope; private Ops(Scope scope) { this.scope = scope; - nn = new NnOps(scope); - summary = new SummaryOps(scope); - image = new ImageOps(scope); - ragged = new RaggedOps(scope); - data = new DataOps(scope); - shape = new ShapeOps(scope); - io = new IoOps(scope); - dtypes = new DtypesOps(scope); - xla = new XlaOps(scope); - linalg = new LinalgOps(scope); - random = new RandomOps(scope); - strings = new StringsOps(scope); - sparse = new SparseOps(scope); - bitwise = new BitwiseOps(scope); - math = new MathOps(scope); - audio = new AudioOps(scope); - signal = new SignalOps(scope); - quantization = new QuantizationOps(scope); - train = new TrainOps(scope); + nn = new NnOps(this); + summary = new SummaryOps(this); + image = new ImageOps(this); + ragged = new RaggedOps(this); + data = new DataOps(this); + shape = new ShapeOps(this); + io = new IoOps(this); + dtypes = new DtypesOps(this); + xla = new XlaOps(this); + linalg = new LinalgOps(this); + random = new RandomOps(this); + strings = new StringsOps(this); + sparse = new SparseOps(this); + bitwise = new BitwiseOps(this); + math = new MathOps(this); + audio = new AudioOps(this); + signal = new SignalOps(this); + train = new TrainOps(this); + quantization = new QuantizationOps(this); } /** diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/QuantizationOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/QuantizationOps.java index aec0d667c65..0a0703a8f5b 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/QuantizationOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/QuantizationOps.java @@ -45,8 +45,11 @@ public final class QuantizationOps { private final Scope scope; - QuantizationOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + QuantizationOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -628,4 +631,11 @@ public Requantize requantize(Operand in Operand requestedOutputMax, DataType outType) { return Requantize.create(scope, input, inputMin, inputMax, requestedOutputMin, requestedOutputMax, outType); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/RaggedOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/RaggedOps.java index 7d585455bdd..59aaae4bd70 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/RaggedOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/RaggedOps.java @@ -30,8 +30,11 @@ public final class RaggedOps { private final Scope scope; - RaggedOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + RaggedOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -60,4 +63,11 @@ public RaggedBincount raggedBincount( RaggedBincount.Options... options) { return RaggedBincount.create(scope, splits, values, size, weights, options); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/RandomOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/RandomOps.java index 071e77c7a70..1dde01b96b1 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/RandomOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/RandomOps.java @@ -52,8 +52,11 @@ public final class RandomOps { private final Scope scope; - RandomOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + RandomOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -583,4 +586,11 @@ public UniformCandidateSampler uniformCandidateSampler(Operand trueClass Long numSampled, Boolean unique, Long rangeMax, UniformCandidateSampler.Options... options) { return UniformCandidateSampler.create(scope, trueClasses, numTrue, numSampled, unique, rangeMax, options); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/ShapeOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/ShapeOps.java index 81c692571f1..5ed7ab60999 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/ShapeOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/ShapeOps.java @@ -34,8 +34,11 @@ public final class ShapeOps { private final Scope scope; - ShapeOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + ShapeOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -469,4 +472,11 @@ public Operand takeLast(Shape shape, Operand public Operand takeLast(Shape shape, Operand n, DataType dType) { return Shapes.takeLast(scope, shape, n, dType); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SignalOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SignalOps.java index f4ec7bdb48d..b71fb5cce13 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SignalOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SignalOps.java @@ -50,8 +50,11 @@ public final class SignalOps { private final Scope scope; - SignalOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + SignalOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -434,4 +437,11 @@ public Rfft3d rfft3d(Operand input, Operand fftLength, DataType Tcomplex) { return Rfft3d.create(scope, input, fftLength, Tcomplex); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SparseOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SparseOps.java index 42cdf9569d9..4bd61718ecc 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SparseOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SparseOps.java @@ -80,8 +80,11 @@ public final class SparseOps { private final Scope scope; - SparseOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + SparseOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -1497,4 +1500,11 @@ public TakeManySparseFromTensorsMap takeManySparseFromTenso TakeManySparseFromTensorsMap.Options... options) { return TakeManySparseFromTensorsMap.create(scope, sparseHandles, dtype, options); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/StringsOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/StringsOps.java index f6491843332..d1f2940bfa2 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/StringsOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/StringsOps.java @@ -52,8 +52,11 @@ public final class StringsOps { private final Scope scope; - StringsOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + StringsOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -617,4 +620,11 @@ public UnsortedSegmentJoin unsortedSegmen public Upper upper(Operand input, Upper.Options... options) { return Upper.create(scope, input, options); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SummaryOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SummaryOps.java index 6143335b8fd..83423d50121 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SummaryOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/SummaryOps.java @@ -37,8 +37,11 @@ public final class SummaryOps { private final Scope scope; - SummaryOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + SummaryOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -195,4 +198,11 @@ public TensorSummary tensorSummary(Operand tag, Opera Operand serializedSummaryMetadata) { return TensorSummary.create(scope, tag, tensor, serializedSummaryMetadata); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/TrainOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/TrainOps.java index 2c5d8752136..d45e2c85425 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/TrainOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/TrainOps.java @@ -98,8 +98,11 @@ public final class TrainOps { private final Scope scope; - TrainOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + TrainOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -1658,4 +1661,11 @@ public SparseApplyRmsProp sparseApplyRms public TileGrad tileGrad(Operand input, Operand multiples) { return TileGrad.create(scope, input, multiples); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/XlaOps.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/XlaOps.java index 535972d4883..585e721733a 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/XlaOps.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/XlaOps.java @@ -49,8 +49,11 @@ public final class XlaOps { private final Scope scope; - XlaOps(Scope scope) { - this.scope = scope; + private final Ops ops; + + XlaOps(Ops ops) { + this.scope = ops.scope(); + this.ops = ops; } /** @@ -379,4 +382,11 @@ public Svd svd(Operand a, Long maxIter, Float epsilon, String precisionConfig) { return Svd.create(scope, a, maxIter, epsilon, precisionConfig); } + + /** + * Get the parent {@link Ops} object. + */ + public final Ops ops() { + return ops; + } } diff --git a/tensorflow-core/tensorflow-core-generator/src/main/java/org/tensorflow/processor/operator/OperatorProcessor.java b/tensorflow-core/tensorflow-core-generator/src/main/java/org/tensorflow/processor/operator/OperatorProcessor.java index d668c5e46d5..16014e5b4b3 100644 --- a/tensorflow-core/tensorflow-core-generator/src/main/java/org/tensorflow/processor/operator/OperatorProcessor.java +++ b/tensorflow-core/tensorflow-core-generator/src/main/java/org/tensorflow/processor/operator/OperatorProcessor.java @@ -428,8 +428,9 @@ private static TypeSpec buildGroupClass(OpsSpec spec) { MethodSpec.Builder ctorBuilder = MethodSpec.constructorBuilder() - .addParameter(T_SCOPE, "scope") - .addStatement("this.scope = scope"); + .addParameter(T_OPS, "ops") + .addStatement("this.scope = ops.scope()") + .addStatement("this.ops = ops"); TypeSpec.Builder builder = TypeSpec.classBuilder(spec.className) @@ -442,13 +443,24 @@ private static TypeSpec buildGroupClass(OpsSpec spec) { T_OPS) .addMethods(spec.methods); - addGroupFields(builder, ctorBuilder, spec.subGroups); + MethodSpec.Builder opsBuilder = MethodSpec.methodBuilder("ops") + .addModifiers(Modifier.PUBLIC, Modifier.FINAL) + .returns(T_OPS) + .addJavadoc("Get the parent {@link " + T_OPS.simpleName() + "} object.") + .addStatement("return ops"); + + builder.addMethod(opsBuilder.build()); + + addGroupFields(builder, ctorBuilder, spec.subGroups, false); builder.addMethod(ctorBuilder.build()); builder.addField( FieldSpec.builder(T_SCOPE, "scope").addModifiers(Modifier.PRIVATE, Modifier.FINAL).build()); + builder.addField( + FieldSpec.builder(T_OPS, "ops").addModifiers(Modifier.PRIVATE, Modifier.FINAL).build()); + return builder.build(); } @@ -497,7 +509,7 @@ private static TypeSpec buildTopClass(OpsSpec spec) { T_OPERATOR) .addMethods(spec.methods); - addGroupFields(opsBuilder, ctorBuilder, spec.subGroups); + addGroupFields(opsBuilder, ctorBuilder, spec.subGroups, true); opsBuilder.addMethod(ctorBuilder.build()); @@ -571,14 +583,14 @@ private static TypeSpec buildTopClass(OpsSpec spec) { return opsBuilder.build(); } - private static void addGroupFields(TypeSpec.Builder classBuilder, MethodSpec.Builder ctorBuilder, List groups) { + private static void addGroupFields(TypeSpec.Builder classBuilder, MethodSpec.Builder ctorBuilder, List groups, boolean isTopClass) { groups.forEach(group -> { classBuilder.addField( FieldSpec.builder(group.className, group.fieldName) .addModifiers(Modifier.PUBLIC, Modifier.FINAL) .build() ); - ctorBuilder.addStatement("$L = new $T(scope)", group.fieldName, group.className).build(); + ctorBuilder.addStatement("$L = new $T(" + (isTopClass ? "this" : "ops") + ")", group.fieldName, group.className).build(); }); }