| 1211 | } |
| 1212 | |
| 1213 | void DefineFunction(const char* name, TF_Function** func, |
| 1214 | const char* description = nullptr, |
| 1215 | bool append_hash = false) { |
| 1216 | std::unique_ptr<TF_Graph, decltype(&TF_DeleteGraph)> func_graph( |
| 1217 | TF_NewGraph(), TF_DeleteGraph); |
| 1218 | std::unique_ptr<TF_Status, decltype(&TF_DeleteStatus)> s(TF_NewStatus(), |
| 1219 | TF_DeleteStatus); |
| 1220 | |
| 1221 | TF_Operation* feed = Placeholder(func_graph.get(), s.get()); |
| 1222 | TF_Operation* neg = Neg(feed, func_graph.get(), s.get()); |
| 1223 | |
| 1224 | TF_Output inputs[] = {{feed, 0}}; |
| 1225 | TF_Output outputs[] = {{neg, 0}}; |
| 1226 | *func = TF_GraphToFunction(func_graph.get(), name, append_hash, -1, |
| 1227 | /*opers=*/nullptr, 1, inputs, 1, outputs, |
| 1228 | /*output_names=*/nullptr, |
| 1229 | /*opts=*/nullptr, description, s.get()); |
| 1230 | ASSERT_EQ(TF_OK, TF_GetCode(s.get())) << TF_Message(s.get()); |
| 1231 | ASSERT_NE(*func, nullptr); |
| 1232 | } |
| 1233 | |
| 1234 | REGISTER_OP("CustomOp") |
| 1235 | .Output("output: float32") |
no test coverage detected