| 130 | } |
| 131 | |
| 132 | func generateFunctionForOp(w io.Writer, op *pb.OpDef, apidef *pb.ApiDef) error { |
| 133 | if strings.HasPrefix(op.Name, "_") { // Internal operation |
| 134 | return nil |
| 135 | } |
| 136 | // Ignore operations where the Go types corresponding to the TensorFlow |
| 137 | // type haven't been worked out (such as "func"s). |
| 138 | for _, a := range op.Attr { |
| 139 | if _, err := goType(a.Type); err != nil { |
| 140 | return nil |
| 141 | } |
| 142 | } |
| 143 | // Also, haven't figured out reference types yet, so ignore those too. |
| 144 | for _, a := range op.InputArg { |
| 145 | if a.IsRef { |
| 146 | return nil |
| 147 | } |
| 148 | } |
| 149 | for _, a := range op.OutputArg { |
| 150 | if a.IsRef { |
| 151 | return nil |
| 152 | } |
| 153 | } |
| 154 | if apidef.Summary == "" { |
| 155 | // Undocumented operation, perhaps a sign of not being ready to |
| 156 | // export. |
| 157 | return nil |
| 158 | } |
| 159 | tmplArgs, err := newTmplArgs(op, apidef) |
| 160 | if err != nil { |
| 161 | return err |
| 162 | } |
| 163 | return tmplOp.Execute(w, tmplArgs) |
| 164 | } |
| 165 | |
| 166 | var ( |
| 167 | // Go keywords that cannot be used as identifiers. |