diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-09-20 12:37:30 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-20 12:44:24 -0700 |
commit | 4aa639c0cbb47f4707f735e0cc80f4c39506d928 (patch) | |
tree | ee87e1b72e0c6a9482e1005f88706f7c193e7a33 /tensorflow/core/api_def | |
parent | 350effcc2fd95c723c92267cf13fcd38777a2a98 (diff) |
Add searchsorted (ie lower/upper bound) op.
PiperOrigin-RevId: 213863392
Diffstat (limited to 'tensorflow/core/api_def')
-rw-r--r-- | tensorflow/core/api_def/base_api/api_def_LowerBound.pbtxt | 45 | ||||
-rw-r--r-- | tensorflow/core/api_def/base_api/api_def_UpperBound.pbtxt | 45 |
2 files changed, 90 insertions, 0 deletions
diff --git a/tensorflow/core/api_def/base_api/api_def_LowerBound.pbtxt b/tensorflow/core/api_def/base_api/api_def_LowerBound.pbtxt new file mode 100644 index 0000000000..5ce825ae04 --- /dev/null +++ b/tensorflow/core/api_def/base_api/api_def_LowerBound.pbtxt @@ -0,0 +1,45 @@ +op { + graph_op_name: "LowerBound" + visibility: HIDDEN + in_arg { + name: "sorted_inputs" + description: <<END +2-D Tensor where each row is ordered. +END + } + in_arg { + name: "values" + description: <<END +2-D Tensor with the same numbers of rows as `sorted_search_values`. Contains +the values that will be searched for in `sorted_search_values`. +END + } + out_arg { + name: "output" + description: <<END +A `Tensor` with the same shape as `values`. It contains the first scalar index +into the last dimension where values can be inserted without changing the +ordered property. +END + } + summary: "Applies lower_bound(sorted_search_values, values) along each row." + description: <<END +Each set of rows with the same index in (sorted_inputs, values) is treated +independently. The resulting row is the equivalent of calling +`np.searchsorted(sorted_inputs, values, side='left')`. + +The result is not a global index to the entire +`Tensor`, but rather just the index in the last dimension. + +A 2-D example: + sorted_sequence = [[0, 3, 9, 9, 10], + [1, 2, 3, 4, 5]] + values = [[2, 4, 9], + [0, 2, 6]] + + result = LowerBound(sorted_sequence, values) + + result == [[1, 2, 2], + [0, 1, 5]] +END +} diff --git a/tensorflow/core/api_def/base_api/api_def_UpperBound.pbtxt b/tensorflow/core/api_def/base_api/api_def_UpperBound.pbtxt new file mode 100644 index 0000000000..0630f6e82a --- /dev/null +++ b/tensorflow/core/api_def/base_api/api_def_UpperBound.pbtxt @@ -0,0 +1,45 @@ +op { + graph_op_name: "UpperBound" + visibility: HIDDEN + in_arg { + name: "sorted_inputs" + description: <<END +2-D Tensor where each row is ordered. +END + } + in_arg { + name: "values" + description: <<END +2-D Tensor with the same numbers of rows as `sorted_search_values`. Contains +the values that will be searched for in `sorted_search_values`. +END + } + out_arg { + name: "output" + description: <<END +A `Tensor` with the same shape as `values`. It contains the last scalar index +into the last dimension where values can be inserted without changing the +ordered property. +END + } + summary: "Applies upper_bound(sorted_search_values, values) along each row." + description: <<END +Each set of rows with the same index in (sorted_inputs, values) is treated +independently. The resulting row is the equivalent of calling +`np.searchsorted(sorted_inputs, values, side='right')`. + +The result is not a global index to the entire +`Tensor`, but rather just the index in the last dimension. + +A 2-D example: + sorted_sequence = [[0, 3, 9, 9, 10], + [1, 2, 3, 4, 5]] + values = [[2, 4, 9], + [0, 2, 6]] + + result = UpperBound(sorted_sequence, values) + + result == [[1, 2, 4], + [0, 2, 5]] +END +} |