From 2bf056fe5a771c5d55d18b006b88b8d41ee50b51 Mon Sep 17 00:00:00 2001 From: "Zhang, Wuxun" Date: Fri, 19 May 2023 14:13:33 +0800 Subject: [PATCH] add new select op and boolean data type --- .../oneDNN/source/graph/data_model.rst | 3 + .../oneDNN/source/graph/ops/Select.rst | 95 +++++++++++++++++++ .../oneDNN/source/graph/ops/index.rst | 1 + 3 files changed, 99 insertions(+) create mode 100644 source/elements/oneDNN/source/graph/ops/Select.rst diff --git a/source/elements/oneDNN/source/graph/data_model.rst b/source/elements/oneDNN/source/graph/data_model.rst index 5914b789a..7089279b7 100644 --- a/source/elements/oneDNN/source/graph/data_model.rst +++ b/source/elements/oneDNN/source/graph/data_model.rst @@ -39,6 +39,9 @@ it's suggested to refer to the definition page of each operation. u8 8-bit unsigned integer. + + boolean + Boolean data type. Size is C++ implementation defined. oneDNN Graph supports both public layout and |opaque| layout. When the diff --git a/source/elements/oneDNN/source/graph/ops/Select.rst b/source/elements/oneDNN/source/graph/ops/Select.rst new file mode 100644 index 000000000..326b54823 --- /dev/null +++ b/source/elements/oneDNN/source/graph/ops/Select.rst @@ -0,0 +1,95 @@ +.. SPDX-FileCopyrightText: 2023 Intel Corporation +.. +.. SPDX-License-Identifier: CC-BY-4.0 +.. include:: ../../replacements.inc.rst + + +Select +###### + +Select operation returns a tensor filled with the elements from the second or +the third input, depending on the condition (the first input) value. + +.. math:: + \dst[i] = cond[i] ? \src\_0[i] : \src\_1[i] + +Broadcasting is supported. + +If the auto_broadcast attribute is not none, the select operation takes a +two-step broadcast before performing the selection: + +- **Step 1**: Input tensors \src\_0 and \src\_1 are broadcasted to dst_shape + according to the Numpy broadcast rules. + +- **Step 2**: Then, the cond tensor will be one-way broadcasted to the + dst_shape of broadcasted \src\_0 and \src\_1. To be more specific, we align + the two shapes to the right and compare them from right to left. Each + dimension should be either equal or the dimension of cond should be 1. + +- **example**: + + - cond={4, 5}, dst_shape={2, 3, 4, 5} => dst = {2, 3, 4, 5} + - cond={3, 1, 5}, dst_shape={2, 3, 4, 5} => dst = {2, 3, 4, 5} + - cond={3,5}, dst_shape={2, 3, 4, 5} => dst = invalid_shape + +Operation Attributes +******************** + ++-------------------+-------------------+------------+------------+-------------+ +| Attribute | Description | Value Type | Supported | Required or | +| Name | | | Values | Optional | ++===================+===================+============+============+=============+ +| |attr_auto_bcast| | Specifies | string | ``none``, | Optional | +| | rules used | | ``numpy``, | | +| | for | | (default) | | +| | auto-broadcasting | | | | +| | of src | | | | +| | tensors | | | | ++-------------------+-------------------+------------+------------+-------------+ + + +Execution Arguments +******************* + +The inputs and outputs must be provided according to the below index order +when constructing an operation. + +Inputs +====== + + +===== ============= ==================== +Index Argument Name Required or Optional +===== ============= ==================== +0 ``cond`` Required +1 ``src_0`` Required +2 ``src_1`` Required +===== ============= ==================== + +@note All input shapes should match and no broadcasting is allowed if the +`auto_broadcast` attribute is set to `none`, or can be broadcasted according to +the broadcasting rules mentioned above if `auto_broadcast` attribute set to +`numpy`. + +Outputs +======= + + +===== ============= ==================== +Index Argument Name Required or Optional +===== ============= ==================== +0 ``dst`` Required +===== ============= ==================== + +Supported Data Types +******************** + +Select operation supports the following data type combinations. + +======= ===== ===== ==== +Cond Src_0 Src_1 Dst +======= ===== ===== ==== +boolean f32 f32 f32 +boolean bf16 bf16 bf16 +boolean f16 f16 f16 +======= ===== ===== ==== diff --git a/source/elements/oneDNN/source/graph/ops/index.rst b/source/elements/oneDNN/source/graph/ops/index.rst index b82181fc2..4f484e0c2 100644 --- a/source/elements/oneDNN/source/graph/ops/index.rst +++ b/source/elements/oneDNN/source/graph/ops/index.rst @@ -75,6 +75,7 @@ subset of the operation set. ReduceSum.rst Reorder.rst Round.rst + Select.rst Sigmoid.rst SigmoidBackward.rst SoftPlus.rst