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

Function _set_operation

tensorflow/python/ops/sets_impl.py:93–133  ·  view source on GitHub ↗

Compute set operation of elements in last dimension of `a` and `b`. All but the last dimension of `a` and `b` must match. Args: a: `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices must be sorted in row-major order. b: `Tensor` or `SparseTensor` of the same

(a, b, set_operation, validate_indices=True)

Source from the content-addressed store, hash-verified

91
92
93def _set_operation(a, b, set_operation, validate_indices=True):
94 """Compute set operation of elements in last dimension of `a` and `b`.
95
96 All but the last dimension of `a` and `b` must match.
97
98 Args:
99 a: `Tensor` or `SparseTensor` of the same type as `b`. If sparse, indices
100 must be sorted in row-major order.
101 b: `Tensor` or `SparseTensor` of the same type as `a`. Must be
102 `SparseTensor` if `a` is `SparseTensor`. If sparse, indices must be
103 sorted in row-major order.
104 set_operation: String indicating set operation. See
105 SetOperationOp::SetOperationFromContext for valid values.
106 validate_indices: Whether to validate the order and range of sparse indices
107 in `a` and `b`.
108
109 Returns:
110 A `SparseTensor` with the same rank as `a` and `b`, and all but the last
111 dimension the same. Elements along the last dimension contain the results
112 of the set operation.
113
114 Raises:
115 TypeError: If inputs are invalid types.
116 ValueError: If `a` is sparse and `b` is dense.
117 """
118 if isinstance(a, sparse_tensor.SparseTensor):
119 if isinstance(b, sparse_tensor.SparseTensor):
120 indices, values, shape = gen_set_ops.sparse_to_sparse_set_operation(
121 a.indices, a.values, a.dense_shape,
122 b.indices, b.values, b.dense_shape,
123 set_operation, validate_indices)
124 else:
125 raise ValueError("Sparse,Dense is not supported, but Dense,Sparse is. "
126 "Please flip the order of your inputs.")
127 elif isinstance(b, sparse_tensor.SparseTensor):
128 indices, values, shape = gen_set_ops.dense_to_sparse_set_operation(
129 a, b.indices, b.values, b.dense_shape, set_operation, validate_indices)
130 else:
131 indices, values, shape = gen_set_ops.dense_to_dense_set_operation(
132 a, b, set_operation, validate_indices)
133 return sparse_tensor.SparseTensor(indices, values, shape)
134
135
136@tf_export(

Callers 3

set_intersectionFunction · 0.85
set_differenceFunction · 0.85
set_unionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected