Skip to content

Commit

Permalink
fix generator type specification and set default values for some opti…
Browse files Browse the repository at this point in the history
…onal attributes. (onnx#419)

* set default value for optional attributes and set value of Constant as required.

* fix generator op type specification bug

* doc updates
  • Loading branch information
linkerzhang authored Jan 17, 2018
1 parent 9935835 commit fa31270
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 23 deletions.
10 changes: 5 additions & 5 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ opset_import {
#### Attributes

<dl>
<dt><tt>value</tt> : tensor</dt>
<dt><tt>value</tt> : tensor (required)</dt>
<dd>The value for the elements of the output tensor.</dd>
</dl>

Expand Down Expand Up @@ -3492,7 +3492,7 @@ opset_import {
<dd>The standard deviation of the normal distribution.</dd>
<dt><tt>seed</tt> : float</dt>
<dd>(Optional) Seed to the random generator, if not specified we will auto generate one.</dd>
<dt><tt>shape</tt> : list of ints</dt>
<dt><tt>shape</tt> : list of ints (required)</dt>
<dd>The shape of the output tensor.</dd>
</dl>

Expand Down Expand Up @@ -3549,7 +3549,7 @@ opset_import {
#### Inputs

<dl>
<dt><tt>input</tt> : T</dt>
<dt><tt>input</tt> : tensor(int32)</dt>
<dd>Input tensor to provide shape information.</dd>
</dl>

Expand Down Expand Up @@ -3597,7 +3597,7 @@ opset_import {
<dd>Lower boundary of the output values.</dd>
<dt><tt>seed</tt> : float</dt>
<dd>(Optional) Seed to the random generator, if not specified we will auto generate one.</dd>
<dt><tt>shape</tt> : list of ints</dt>
<dt><tt>shape</tt> : list of ints (required)</dt>
<dd>The shape of the output tensor.</dd>
</dl>

Expand Down Expand Up @@ -3653,7 +3653,7 @@ opset_import {
#### Inputs

<dl>
<dt><tt>input</tt> : T</dt>
<dt><tt>input</tt> : tensor(int32)</dt>
<dd>Input tensor to provide shape information.</dd>
</dl>

Expand Down
10 changes: 5 additions & 5 deletions docs/Operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ opset_import {
#### Attributes

<dl>
<dt><tt>value</tt> : tensor</dt>
<dt><tt>value</tt> : tensor (required)</dt>
<dd>The value for the elements of the output tensor.</dd>
</dl>

Expand Down Expand Up @@ -3261,7 +3261,7 @@ opset_import {
<dd>The standard deviation of the normal distribution.</dd>
<dt><tt>seed</tt> : float</dt>
<dd>(Optional) Seed to the random generator, if not specified we will auto generate one.</dd>
<dt><tt>shape</tt> : list of ints</dt>
<dt><tt>shape</tt> : list of ints (required)</dt>
<dd>The shape of the output tensor.</dd>
</dl>

Expand Down Expand Up @@ -3319,7 +3319,7 @@ opset_import {
#### Inputs

<dl>
<dt><tt>input</tt> : T</dt>
<dt><tt>input</tt> : tensor(int32)</dt>
<dd>Input tensor to provide shape information.</dd>
</dl>

Expand Down Expand Up @@ -3368,7 +3368,7 @@ opset_import {
<dd>Lower boundary of the output values.</dd>
<dt><tt>seed</tt> : float</dt>
<dd>(Optional) Seed to the random generator, if not specified we will auto generate one.</dd>
<dt><tt>shape</tt> : list of ints</dt>
<dt><tt>shape</tt> : list of ints (required)</dt>
<dd>The shape of the output tensor.</dd>
</dl>

Expand Down Expand Up @@ -3425,7 +3425,7 @@ opset_import {
#### Inputs

<dl>
<dt><tt>input</tt> : T</dt>
<dt><tt>input</tt> : tensor(int32)</dt>
<dd>Input tensor to provide shape information.</dd>
</dl>

Expand Down
2 changes: 1 addition & 1 deletion onnx/defs/experiments/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ OPERATOR_SCHEMA(Scale)
Scale takes one input data (Tensor<float>) and produces one output data
(Tensor<float>) whose value is the input data tensor scaled element-wise.
)DOC")
.Attr("scale", "(float, default 1.0) the scale to apply.", AttributeProto::FLOAT, OPTIONAL);
.Attr("scale", "(float, default 1.0) the scale to apply.", AttributeProto::FLOAT, 1.0f);

OPERATOR_SCHEMA(GRUUnit)
.SetSupportLevel(SupportType::EXPERIMENTAL)
Expand Down
13 changes: 5 additions & 8 deletions onnx/defs/generator/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ OPERATOR_SCHEMA(Constant)
.Attr(
"value",
"The value for the elements of the output tensor.",
AttributeProto::TENSOR,
OPTIONAL)
AttributeProto::TENSOR)
.Output(
0,
"output",
Expand Down Expand Up @@ -50,8 +49,7 @@ TensorProto message.
.Attr(
"shape",
"The shape of the output tensor.",
AttributeProto::INTS,
OPTIONAL)
AttributeProto::INTS)
.Output(
0,
"output",
Expand Down Expand Up @@ -92,8 +90,7 @@ TensorProto message.
.Attr(
"shape",
"The shape of the output tensor.",
AttributeProto::INTS,
OPTIONAL)
AttributeProto::INTS)
.Output(
0,
"output",
Expand Down Expand Up @@ -134,7 +131,7 @@ TensorProto message.
.Input(
0,
"input",
"Input tensor to provide shape information.", "T")
"Input tensor to provide shape information.", "tensor(int32)")
.Output(
0,
"output",
Expand Down Expand Up @@ -176,7 +173,7 @@ TensorProto message.
.Input(
0,
"input",
"Input tensor to provide shape information.", "T")
"Input tensor to provide shape information.", "tensor(int32)")
.Output(
0,
"output",
Expand Down
2 changes: 1 addition & 1 deletion onnx/defs/logical/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ detailed description of the broadcasting rules.
)DOC";
ReplaceAll(doc, "{name}", name);
schema.SetDoc(doc);
schema.Attr("broadcast", "Enable broadcasting", AttributeProto::INT, OPTIONAL);
schema.Attr("broadcast", "Enable broadcasting", AttributeProto::INT, static_cast<int64_t>(0));
schema.Attr("axis", "If set, defines the broadcast dimensions.",
AttributeProto::INT,
OPTIONAL);
Expand Down
4 changes: 2 additions & 2 deletions onnx/defs/nn/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace onnx {
AttributeProto::INTS, OPTIONAL);
schema.Attr("p",
"p value of the Lp norm used to pool over the input data, default is 2.",
AttributeProto::INT, OPTIONAL);
AttributeProto::INT, static_cast<int64_t>(2));
schema.Input(0,
"X",
"Input data tensor from the previous operator; "
Expand Down Expand Up @@ -345,7 +345,7 @@ namespace onnx {
schema.Attr("p",
"p value of the Lp norm used to pool over the input data, default is 2.",
AttributeProto::INT,
OPTIONAL);
static_cast<int64_t>(2));
schema.Input(0,
"X",
"Input data tensor from the previous operator; "
Expand Down
2 changes: 1 addition & 1 deletion onnx/defs/rnn/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Equations (Default: f=Tanh):
"input gate. The activation function must be one of the activation "
"functions specified above. Optional: Default `Tanh` if not specified.",
AttributeProto::STRINGS,
OPTIONAL)
std::vector<std::string>{"Tanh", "Tanh"})
.Input(1, "W",
"The weight tensor for input gate. Concatenation of `Wi` and `WBi` "
"(if bidirectional). The tensor has shape "
Expand Down

0 comments on commit fa31270

Please sign in to comment.