{"action":"created","issue":{"url":"https://api.github.com/repos/onnx/onnx/issues/481","repository_url":"https://api.github.com/repos/onnx/onnx","labels_url":"https://api.github.com/repos/onnx/onnx/issues/481/labels{/name}","comments_url":"https://api.github.com/repos/onnx/onnx/issues/481/comments","events_url":"https://api.github.com/repos/onnx/onnx/issues/481/events","html_url":"https://github.com/onnx/onnx/issues/481","id":291815949,"number":481,"title":"Add function support in onnx","user":{"login":"linkerzhang","id":5194557,"avatar_url":"https://avatars2.githubusercontent.com/u/5194557?v=4","gravatar_id":"","url":"https://api.github.com/users/linkerzhang","html_url":"https://github.com/linkerzhang","followers_url":"https://api.github.com/users/linkerzhang/followers","following_url":"https://api.github.com/users/linkerzhang/following{/other_user}","gists_url":"https://api.github.com/users/linkerzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/linkerzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkerzhang/subscriptions","organizations_url":"https://api.github.com/users/linkerzhang/orgs","repos_url":"https://api.github.com/users/linkerzhang/repos","events_url":"https://api.github.com/users/linkerzhang/events{/privacy}","received_events_url":"https://api.github.com/users/linkerzhang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-01-26T07:07:01Z","updated_at":"2018-02-19T15:39:29Z","closed_at":null,"author_association":"MEMBER","body":"Proposal as below, feel free to share your comments please. Thank you very much! @dzhulgakov @yuanbyu @ezyang @bddppq @ebarsoum @gramalingam \r\n\r\nYou may refer to the whole proto file https://github.com/linkerzhang/onnx/blob/kezhan/add_function_to_onnx/onnx/onnx.in.proto.\r\n\r\n```\r\n// A named attribute containing either singular float, integer, string\r\n// and tensor values, or repeated float, integer, string and tensor values.\r\n// An AttributeProto MUST contain the name field, and *only one* of the\r\n// following content fields, effectively enforcing a C/C++ union equivalent.\r\nmessage AttributeProto {\r\n\r\n  // Note: this enum is structurally identical to the OpSchema::AttrType\r\n  // enum defined in schema.h.  If you rev one, you likely need to rev the other.\r\n  enum AttributeType {\r\n    UNDEFINED = 0;\r\n    FLOAT = 1;\r\n    INT = 2;\r\n    STRING = 3;\r\n    TENSOR = 4;\r\n    GRAPH = 5;\r\n\r\n    FLOATS = 6;\r\n    INTS = 7;\r\n    STRINGS = 8;\r\n    TENSORS = 9;\r\n    GRAPHS = 10;\r\n  }\r\n\r\n  // The name field MUST be present for this version of the IR.\r\n  optional string name = 1;           // namespace Attribute\r\n  optional bool is_ref = 21;          // if it's true, it means it's referring parent node's (referring to a function) attribute value.\r\n  optional string ref_attr_name = 22; // if is_ref is true, ref_attr_name is the attribute name in parent function.\r\n\r\n  // A human-readable documentation for this attribute. Markdown is allowed.\r\n  optional string doc_string = 13;\r\n\r\n  // The type field MUST be present for this version of the IR.\r\n  // For 0.0.1 versions of the IR, this field was not defined, and\r\n  // implementations needed to use has_field hueristics to determine\r\n  // which value field was in use.  For IR_VERSION 0.0.2 or later, this\r\n  // field MUST be set and match the f|i|s|t|... field in use.  This\r\n  // change was made to accomodate proto3 implementations.\r\n  optional AttributeType type = 20;   // discriminator that indicates which field below is in use\r\n\r\n  // Exactly ONE of the following fields must be present for this version of the IR\r\n  optional float f = 2;               // float\r\n  optional int64 i = 3;               // int\r\n  optional bytes s = 4;               // UTF-8 string\r\n  optional TensorProto t = 5;         // tensor value\r\n  optional GraphProto g = 6;          // graph\r\n  // Do not use field below, it's deprecated.\r\n  // optional ValueProto v = 12;         // value - subsumes everything but graph\r\n\r\n  repeated float floats = 7;          // list of floats\r\n  repeated int64 ints = 8;            // list of ints\r\n  repeated bytes strings = 9;         // list of UTF-8 strings\r\n  repeated TensorProto tensors = 10;  // list of tensors\r\n  repeated GraphProto graphs = 11;    // list of graph\r\n}\r\n\r\n// Defines a function parameter.\r\nmessage ParameterDeclProto {\r\n  // The name of this parameter. Must be present.\r\n  optional string name = 1;\r\n\r\n  // The type/shape of this parameter.\r\n  optional TypeProto type = 2; \r\n\r\n  // A human-readable doc string for this parameter. \r\n  optional string doc_string = 3; \r\n} \r\n\r\n// Defines a function attribute declaration.\r\nmessage FuncAttrDeclProto {\r\n  // The attribute name of the function. Must be present.\r\n  optional string name = 1;\r\n\r\n  // The type of this attribute.\r\n  optional AttributeProto.AttributeType type = 2;\r\n} \r\n\r\n// Defines a custom implementation of a function. \r\nmessage FunctionImplProto { \r\n  // The domain of this function implementation.\r\n  optional string function_impl_domain = 1; \r\n\r\n  // The version of this implementation.\r\n  optional int64 function_impl_version = 2; \r\n\r\n  // The URI of the executable. A runtime uses <domain> and <version> to\r\n  // determine whether Compilation data itself saved in a separate file. \r\n  optional string executable_uri = 3;\r\n\r\n  // The actual executable for this function implementation.\r\n  optional bytes executable = 4;\r\n} \r\n \r\n// Defines a function.\r\n// We specify a function as a subgraph composed of ONNX ops. Any runtime can\r\n// have a custom implementation optimized for the runtime. A runtime can use\r\n// a matching custom implementation if there is one, or falls back to execute\r\n// the subgraph.\r\n// NOTE: We don't support recursive function.\r\nmessage FunctionDefProto { \r\n  // The name of the function. MUST be present for this version of the IR. \r\n  optional string name = 1;\r\n  \r\n  // The domain of the function.\r\n  optional string domain = 2;\r\n\r\n  // The version of the function.\r\n  optional int64 version = 3;\r\n\r\n  // The input parameters of the function. \r\n  repeated ParameterDeclProto input_params = 4; \r\n\r\n  // The output parameters of the function. \r\n  repeated ParameterDeclProto output_params = 5;\r\n\r\n  // The body of the function. \r\n  repeated NodeProto node = 6;\r\n\r\n  // The function attributes' declaration.\r\n  repeated FuncAttrDeclProto attr = 7;\r\n\r\n  // An optional human-readable documentation for this function in the graph. \r\n  // MAY contain Markdown markup that conforms to http://commonmark.org/. \r\n  optional string doc_string = 8;\r\n\r\n  // Custom implementations of this function. This enables runtime specific\r\n  // implementations.\r\n  repeated FunctionImplProto impl = 9;\r\n \r\n  reserved 100 to 200; // for future extensions. \r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/onnx/onnx/issues/comments/366729012","html_url":"https://github.com/onnx/onnx/issues/481#issuecomment-366729012","issue_url":"https://api.github.com/repos/onnx/onnx/issues/481","id":366729012,"user":{"login":"RanACohen","id":25635287,"avatar_url":"https://avatars3.githubusercontent.com/u/25635287?v=4","gravatar_id":"","url":"https://api.github.com/users/RanACohen","html_url":"https://github.com/RanACohen","followers_url":"https://api.github.com/users/RanACohen/followers","following_url":"https://api.github.com/users/RanACohen/following{/other_user}","gists_url":"https://api.github.com/users/RanACohen/gists{/gist_id}","starred_url":"https://api.github.com/users/RanACohen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RanACohen/subscriptions","organizations_url":"https://api.github.com/users/RanACohen/orgs","repos_url":"https://api.github.com/users/RanACohen/repos","events_url":"https://api.github.com/users/RanACohen/events{/privacy}","received_events_url":"https://api.github.com/users/RanACohen/received_events","type":"User","site_admin":false},"created_at":"2018-02-19T15:39:29Z","updated_at":"2018-02-19T15:39:29Z","author_association":"NONE","body":"I like the : [ref attribute change](https://github.com/linkerzhang/onnx/blob/kezhan/add_function/onnx/onnx.in.proto#L105)\r\nBut I do not understand the motivation of [adding function definition](https://github.com/linkerzhang/onnx/blob/kezhan/add_function/onnx/onnx.in.proto#L500). \r\n\r\nThis whole feature (which as HW Vendor rep I like) can be implemented using graph definition which already exists + the ability to share attributes. why do we need to over-complicate the protobuf?\r\n"}}
{"actor":{"display_login":"RanACohen"}}