MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / DefineFunction

Function DefineFunction

tensorflow/c/c_api_function_test.cc:1213–1232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1211}
1212
1213void 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
1234REGISTER_OP("CustomOp")
1235 .Output("output: float32")

Callers 1

TEST_FFunction · 0.85

Calls 8

TF_NewGraphFunction · 0.85
TF_NewStatusFunction · 0.85
TF_GraphToFunctionFunction · 0.85
TF_GetCodeFunction · 0.85
TF_MessageFunction · 0.85
PlaceholderFunction · 0.70
NegFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected