Skip to content

Commit

Permalink
Remove redundant field
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Yang committed Feb 26, 2019
1 parent b3bb0a5 commit cdbe6b4
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 41 deletions.
1 change: 0 additions & 1 deletion onnx/checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ void check_function(
const CheckerContext& ctx,
const LexicalScopeContext& /*parent_lex*/) {
enforce_non_empty_field(function, name);
enforce_has_field(function, since_version);

std::unordered_set<std::string> output_names;
for (const auto& input : function.input()) {
Expand Down
13 changes: 0 additions & 13 deletions onnx/defs/experiments/experiments_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,9 @@ using SupportType = ONNX_NAMESPACE::OpSchema::SupportType;
static FunctionProto BuildMVN() {
FunctionProto func;
func.set_name("MeanVarianceNormalization");
func.set_doc_string(
"A MeanVarianceNormalization Function: Perform mean variance normalization "
"on the input tensor X using formula: <br/> ``` (X-EX)/sqrt(E(X-EX)^2) ``` <br/><br/>"
"<b>INPUT: </b>X(float/float16/double) with shape [N,C,W,H] or N-D shape <br/><br/>"
"<b>ATTRIBUTE: </b><br/>&nbsp;&nbsp;&nbsp;&nbsp;<tt>axes: </tt>will be passed to ReducedMean "
"Ops. Use [0,2,3] (without C axis for N-D cases) for calculating means and variances "
"along channels. Two variables with the same C-coordinate are associated "
"with the same mean and variance. Use [0,1,2,3] (with C axis) to calculate "
"global mean and global variance with all variables sharing the same mean/variance.<br/>"
"&nbsp;&nbsp;&nbsp;&nbsp;(The KeepDims attribute in ReducedMean is set to true for calculation)<br/>"
"<br/><b>OUTPUT: </b>X_MVN(float/float16/double) with the same shape as input X<br/>");
func.set_since_version(9);
func.add_input("X");
func.add_output("X_MVN");
func.add_attribute("axes");
func.set_status(OperatorStatus::STABLE);

NodeProto* initial_node0 = func.add_node();
BuildNode(
Expand Down
18 changes: 0 additions & 18 deletions onnx/onnx-operators.in.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@ enum OperatorStatus {
message FunctionProto {
// The name of the function, similar usage of op_type in OperatorProto.
optional string name = 1;

// The first version of a function set which contains this function.
// When there's any breaking change for this function, the function set
// contains the function needs to bump its version, and since_version of
// the updated function will be changed to the updated function set version.
optional int64 since_version = 2;

// This field indicates whether the syntax, semantics, or presence
// of this function is in an experimental or stable stage. Once an
// function is published as STABLE, its syntax and semantics MUST NOT
// change in subsequent versions of the operator set.
// When a function is published as EXPERIMENTAL, the syntax and semantics
// of the function MAY change across operator set versions.
// Functions "become" stable by deprecating the experimental version and
// introducing a new stable function with the same name.
optional OperatorStatus status = 3;

// The inputs and outputs of the function.
repeated string input = 4;
Expand All @@ -61,8 +45,6 @@ message FunctionProto {

// The nodes in the function.
repeated NodeProto node = 7;
// A human-readable documentation for this function. Markdown is allowed.
optional string doc_string = 8;
}

// An OperatorProto represents the immutable specification of the signature
Expand Down
5 changes: 3 additions & 2 deletions onnx/shape_inference/implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static void InferShapesImpl(
} else if (schema->has_function_body()) {
try {
InferShapeForFunctionNode(
*schema->GetFunctionBody(), schema_registry, ctx);
*schema->GetFunctionBody(), schema_registry, schema->since_version(), ctx);
} catch (const ONNX_NAMESPACE::InferenceError& function_ex) {
(void)function_ex;
continue;
Expand Down Expand Up @@ -249,8 +249,9 @@ void InferShapes(
void InferShapeForFunctionNode(
const FunctionProto& func,
const ISchemaRegistry* schema_registry,
const int since_version,
InferenceContext& ctx) {
int domain_version = (int)func.since_version();
int domain_version = since_version;
GraphProto g;
// Get a temporary tensor-shape map
std::unordered_map<std::string, TypeProto*> temp_valueTypesByName;
Expand Down
1 change: 1 addition & 0 deletions onnx/shape_inference/implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ void InferShapes(
void InferShapeForFunctionNode(
const FunctionProto& func,
const ISchemaRegistry* schema_registry,
const int since_version,
InferenceContext& ctx);

} // namespace shape_inference
Expand Down
8 changes: 1 addition & 7 deletions onnx/test/cpp/function_verify_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,10 @@ void VerifyFunction(const OpSchema& op, const FunctionProto* function_proto) {
}
CheckerContext ctx;
std::unordered_map<std::string, int> op_set;
if ((int)function_proto->since_version() != op.since_version()) {
fail_check("Unmatched since_version defined in function op '", op.Name(), "'");
}

auto version_range =
OpSchemaRegistry::DomainToVersionRange::Instance().Map().at(
op.domain());
if (function_proto->since_version() > version_range.second ||
function_proto->since_version() < version_range.first) {
fail_check("Invalid function version in function op '", op.Name(), "'");
}

op_set.insert(
{op.domain(), op.since_version()});
Expand Down

0 comments on commit cdbe6b4

Please sign in to comment.