Skip to content

Commit 00101bf

Browse files
spandantiwarihouseroad
authored andcommitted
Remove ConstantLike op. Updates to ConstantOfShape op. (#1716)
* Remove ConstantLike op. Updates to ConstantOfShape op. * Updating Changelog.md and Operator.md files. * Fix build failure. * Updating allowed types for input.
1 parent c59e90a commit 00101bf

File tree

14 files changed

+89
-392
lines changed

14 files changed

+89
-392
lines changed

docs/Changelog.md

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8556,56 +8556,6 @@ This version of the operator has been available since version 9 of the default O
85568556
<dd>Constrain input and output types to all tensor types.</dd>
85578557
</dl>
85588558

8559-
### <a name="ConstantLike-9"></a>**ConstantLike-9**</a>
8560-
8561-
Generate a tensor with specific constant value. The value can be specified by the 'value'
8562-
attribute. The shape of the output tensor is the same as the input tensor, if the input
8563-
tensor is provided, or the shape provided in the 'shape' attribute (if both are provided,
8564-
the input tensor shape takes precendence). The data type can be specified by the 'dtype'
8565-
argument. If 'dtype' is not specified, then the type of input tensor is used. If input
8566-
tensor is also not specified, then the type defaults to 'float'.
8567-
8568-
The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the
8569-
TensorProto message and be valid as an output type.
8570-
8571-
#### Version
8572-
8573-
This version of the operator has been available since version 9 of the default ONNX operator set.
8574-
8575-
#### Attributes
8576-
8577-
<dl>
8578-
<dt><tt>dtype</tt> : int</dt>
8579-
<dd>(Optional) The data type for the elements of the output tensor. If not specified,the data type of the input tensor T1 is used. If input tensor T1 is also not specified, then output tensor type defaults to 'float'.</dd>
8580-
<dt><tt>shape</tt> : list of ints</dt>
8581-
<dd>(Optional) The shape of the output tensor. If input tensor T1 is provided, then 'shape' attribute is ignored and the output follows the shape of the input. One of either input tensor T1 or 'shape' attribute must be provided.</dd>
8582-
<dt><tt>value</tt> : float (default is 0.0)</dt>
8583-
<dd>(Optional) The value for the elements of the output tensor.</dd>
8584-
</dl>
8585-
8586-
#### Inputs (0 - 1)
8587-
8588-
<dl>
8589-
<dt><tt>input</tt> (optional) : T1</dt>
8590-
<dd>Input tensor to copy shape, and optionally, type information from. One of either input tensor T1 or 'shape' attribute must be provided.</dd>
8591-
</dl>
8592-
8593-
#### Outputs
8594-
8595-
<dl>
8596-
<dt><tt>output</tt> : T2</dt>
8597-
<dd>Output tensor, same shape as input tensor T1.</dd>
8598-
</dl>
8599-
8600-
#### Type Constraints
8601-
8602-
<dl>
8603-
<dt><tt>T1</tt> : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)</dt>
8604-
<dd>Constrain input types. Strings and complex are not supported.</dd>
8605-
<dt><tt>T2</tt> : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)</dt>
8606-
<dd>Constrain output types. Strings and complex are not supported.</dd>
8607-
</dl>
8608-
86098559
### <a name="ConstantOfShape-9"></a>**ConstantOfShape-9**</a>
86108560

86118561
Generate a tensor with given value and shape.
@@ -8618,27 +8568,27 @@ This version of the operator has been available since version 9 of the default O
86188568

86198569
<dl>
86208570
<dt><tt>value</tt> : tensor</dt>
8621-
<dd>(Optional) The value of the output elements.Should be a one-element tensor. </dd>
8571+
<dd>(Optional) The value of the output elements.Should be a one-element tensor. If not specified, it defaults to a tensor of value 0 and datatype float32</dd>
86228572
</dl>
86238573

86248574
#### Inputs
86258575

86268576
<dl>
86278577
<dt><tt>input</tt> : T1</dt>
8628-
<dd>1D tensor, The shape of the expected output tensor. If empty tensor is given, the output would be a scalar.</dd>
8578+
<dd>1D tensor. The shape of the expected output tensor. If empty tensor is given, the output would be a scalar.</dd>
86298579
</dl>
86308580

86318581
#### Outputs
86328582

86338583
<dl>
86348584
<dt><tt>output</tt> : T2</dt>
8635-
<dd>Output tensor, using input as shape.If attribute 'value' exist, all value and datatype of output tensor equal to 'value'.Else, all value equal to 0, and datatype default to float32</dd>
8585+
<dd>Output tensor of shape specified by 'input'.If attribute 'value' is specified, the value and datatype of the output tensor is taken from 'value'.If attribute 'value' is not specified, the value in the output defaults to 0, and the datatype defaults to float32.</dd>
86368586
</dl>
86378587

86388588
#### Type Constraints
86398589

86408590
<dl>
8641-
<dt><tt>T1</tt> : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64)</dt>
8591+
<dt><tt>T1</tt> : tensor(int32), tensor(int64)</dt>
86428592
<dd>Constrain input types. Shape must be unsigned integers.</dd>
86438593
<dt><tt>T2</tt> : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)</dt>
86448594
<dd>Constrain output types to be numerics.</dd>

docs/Operators.md

Lines changed: 4 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
* <a href="#Compress">Compress</a>
2424
* <a href="#Concat">Concat</a>
2525
* <a href="#Constant">Constant</a>
26-
* <a href="#ConstantLike">ConstantLike</a>
2726
* <a href="#ConstantOfShape">ConstantOfShape</a>
2827
* <a href="#Conv">Conv</a>
2928
* <a href="#ConvTranspose">ConvTranspose</a>
@@ -2080,117 +2079,6 @@ expect(node, inputs=[], outputs=[values],
20802079
</details>
20812080

20822081

2083-
### <a name="ConstantLike"></a><a name="constantlike">**ConstantLike**</a>
2084-
2085-
Generate a tensor with specific constant value. The value can be specified by the 'value'
2086-
attribute. The shape of the output tensor is the same as the input tensor, if the input
2087-
tensor is provided, or the shape provided in the 'shape' attribute (if both are provided,
2088-
the input tensor shape takes precendence). The data type can be specified by the 'dtype'
2089-
argument. If 'dtype' is not specified, then the type of input tensor is used. If input
2090-
tensor is also not specified, then the type defaults to 'float'.
2091-
2092-
The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the
2093-
TensorProto message and be valid as an output type.
2094-
2095-
#### Version
2096-
2097-
This version of the operator has been available since version 9 of the default ONNX operator set.
2098-
2099-
#### Attributes
2100-
2101-
<dl>
2102-
<dt><tt>dtype</tt> : int</dt>
2103-
<dd>(Optional) The data type for the elements of the output tensor. If not specified,the data type of the input tensor T1 is used. If input tensor T1 is also not specified, then output tensor type defaults to 'float'.</dd>
2104-
<dt><tt>shape</tt> : list of ints</dt>
2105-
<dd>(Optional) The shape of the output tensor. If input tensor T1 is provided, then 'shape' attribute is ignored and the output follows the shape of the input. One of either input tensor T1 or 'shape' attribute must be provided.</dd>
2106-
<dt><tt>value</tt> : float (default is 0.0)</dt>
2107-
<dd>(Optional) The value for the elements of the output tensor.</dd>
2108-
</dl>
2109-
2110-
#### Inputs (0 - 1)
2111-
2112-
<dl>
2113-
<dt><tt>input</tt> (optional) : T1</dt>
2114-
<dd>Input tensor to copy shape, and optionally, type information from. One of either input tensor T1 or 'shape' attribute must be provided.</dd>
2115-
</dl>
2116-
2117-
#### Outputs
2118-
2119-
<dl>
2120-
<dt><tt>output</tt> : T2</dt>
2121-
<dd>Output tensor, same shape as input tensor T1.</dd>
2122-
</dl>
2123-
2124-
#### Type Constraints
2125-
2126-
<dl>
2127-
<dt><tt>T1</tt> : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)</dt>
2128-
<dd>Constrain input types. Strings and complex are not supported.</dd>
2129-
<dt><tt>T2</tt> : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)</dt>
2130-
<dd>Constrain output types. Strings and complex are not supported.</dd>
2131-
</dl>
2132-
2133-
2134-
#### Examples
2135-
2136-
<details>
2137-
<summary>ones_with_input</summary>
2138-
2139-
```python
2140-
shape = (4, 3, 2)
2141-
node = onnx.helper.make_node(
2142-
'ConstantLike',
2143-
inputs=['x'],
2144-
outputs=['y'],
2145-
value=1.0,
2146-
)
2147-
x = np.random.randint(0, 100, size=shape, dtype=np.int32)
2148-
y = np.ones(shape, dtype=np.int32)
2149-
expect(node, inputs=[x], outputs=[y], name='test_constantlike_ones_with_input')
2150-
```
2151-
2152-
</details>
2153-
2154-
2155-
<details>
2156-
<summary>threes_with_shape_and_dtype</summary>
2157-
2158-
```python
2159-
shape = (3, 4)
2160-
node = onnx.helper.make_node(
2161-
'ConstantLike',
2162-
shape=shape,
2163-
inputs=[],
2164-
outputs=['y'],
2165-
value=3.0,
2166-
dtype=onnx.TensorProto.DOUBLE, # 11: DOUBLE
2167-
)
2168-
2169-
y = 3.0 * np.ones(shape, dtype=np.float64)
2170-
expect(node, inputs=[], outputs=[y], name='test_constantlike_threes_with_shape_and_dtype')
2171-
```
2172-
2173-
</details>
2174-
2175-
2176-
<details>
2177-
<summary>zeros_without_input_dtype</summary>
2178-
2179-
```python
2180-
shape = (2, 5, 1)
2181-
node = onnx.helper.make_node(
2182-
'ConstantLike',
2183-
inputs=[],
2184-
outputs=['y'],
2185-
shape=shape,
2186-
)
2187-
y = np.zeros(shape, dtype=np.float32)
2188-
expect(node, inputs=[], outputs=[y], name='test_constantlike_zeros_without_input_dtype')
2189-
```
2190-
2191-
</details>
2192-
2193-
21942082
### <a name="ConstantOfShape"></a><a name="constantofshape">**ConstantOfShape**</a>
21952083

21962084
Generate a tensor with given value and shape.
@@ -2203,27 +2091,27 @@ This version of the operator has been available since version 9 of the default O
22032091

22042092
<dl>
22052093
<dt><tt>value</tt> : tensor</dt>
2206-
<dd>(Optional) The value of the output elements.Should be a one-element tensor. </dd>
2094+
<dd>(Optional) The value of the output elements.Should be a one-element tensor. If not specified, it defaults to a tensor of value 0 and datatype float32</dd>
22072095
</dl>
22082096

22092097
#### Inputs
22102098

22112099
<dl>
22122100
<dt><tt>input</tt> : T1</dt>
2213-
<dd>1D tensor, The shape of the expected output tensor. If empty tensor is given, the output would be a scalar.</dd>
2101+
<dd>1D tensor. The shape of the expected output tensor. If empty tensor is given, the output would be a scalar.</dd>
22142102
</dl>
22152103

22162104
#### Outputs
22172105

22182106
<dl>
22192107
<dt><tt>output</tt> : T2</dt>
2220-
<dd>Output tensor, using input as shape.If attribute 'value' exist, all value and datatype of output tensor equal to 'value'.Else, all value equal to 0, and datatype default to float32</dd>
2108+
<dd>Output tensor of shape specified by 'input'.If attribute 'value' is specified, the value and datatype of the output tensor is taken from 'value'.If attribute 'value' is not specified, the value in the output defaults to 0, and the datatype defaults to float32.</dd>
22212109
</dl>
22222110

22232111
#### Type Constraints
22242112

22252113
<dl>
2226-
<dt><tt>T1</tt> : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64)</dt>
2114+
<dt><tt>T1</tt> : tensor(int32), tensor(int64)</dt>
22272115
<dd>Constrain input types. Shape must be unsigned integers.</dd>
22282116
<dt><tt>T2</tt> : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)</dt>
22292117
<dd>Constrain output types to be numerics.</dd>

docs/TestCoverage.md

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* [Overall Test Coverage](#overall-test-coverage)
66
# Node Test Coverage
77
## Summary
8-
Node tests have covered 107/114 (93.86%, 5 generators excluded) common operators.
8+
Node tests have covered 106/113 (93.81%, 5 generators excluded) common operators.
99

1010
Node tests have covered 2/12 (16.67%, 0 generators excluded) experimental operators.
1111

@@ -1172,62 +1172,6 @@ expect(node, inputs=[], outputs=[values],
11721172
</details>
11731173

11741174

1175-
### ConstantLike
1176-
There are 3 test cases, listed as following:
1177-
<details>
1178-
<summary>ones_with_input</summary>
1179-
1180-
```python
1181-
shape = (4, 3, 2)
1182-
node = onnx.helper.make_node(
1183-
'ConstantLike',
1184-
inputs=['x'],
1185-
outputs=['y'],
1186-
value=1.0,
1187-
)
1188-
x = np.random.randint(0, 100, size=shape, dtype=np.int32)
1189-
y = np.ones(shape, dtype=np.int32)
1190-
expect(node, inputs=[x], outputs=[y], name='test_constantlike_ones_with_input')
1191-
```
1192-
1193-
</details>
1194-
<details>
1195-
<summary>threes_with_shape_and_dtype</summary>
1196-
1197-
```python
1198-
shape = (3, 4)
1199-
node = onnx.helper.make_node(
1200-
'ConstantLike',
1201-
shape=shape,
1202-
inputs=[],
1203-
outputs=['y'],
1204-
value=3.0,
1205-
dtype=onnx.TensorProto.DOUBLE, # 11: DOUBLE
1206-
)
1207-
1208-
y = 3.0 * np.ones(shape, dtype=np.float64)
1209-
expect(node, inputs=[], outputs=[y], name='test_constantlike_threes_with_shape_and_dtype')
1210-
```
1211-
1212-
</details>
1213-
<details>
1214-
<summary>zeros_without_input_dtype</summary>
1215-
1216-
```python
1217-
shape = (2, 5, 1)
1218-
node = onnx.helper.make_node(
1219-
'ConstantLike',
1220-
inputs=[],
1221-
outputs=['y'],
1222-
shape=shape,
1223-
)
1224-
y = np.zeros(shape, dtype=np.float32)
1225-
expect(node, inputs=[], outputs=[y], name='test_constantlike_zeros_without_input_dtype')
1226-
```
1227-
1228-
</details>
1229-
1230-
12311175
### ConstantOfShape
12321176
There are 2 test cases, listed as following:
12331177
<details>

onnx/backend/test/case/node/constantlike.py

Lines changed: 0 additions & 53 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

onnx/backend/test/data/node/test_constantlike_zeros_without_input_dtype/model.onnx

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)