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

Function DefineStatefulFunction

tensorflow/c/c_api_function_test.cc:1595–1616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1593}
1594
1595void DefineStatefulFunction(const char* name, TF_Function** func) {
1596 std::unique_ptr<TF_Graph, decltype(&TF_DeleteGraph)> func_graph(
1597 TF_NewGraph(), TF_DeleteGraph);
1598 std::unique_ptr<TF_Status, decltype(&TF_DeleteStatus)> s(TF_NewStatus(),
1599 TF_DeleteStatus);
1600
1601 TF_Tensor* tensor_shape = Int32Tensor({37, 1});
1602 TF_Operation* shape = Const(tensor_shape, func_graph.get(), s.get(), "shape");
1603 TF_Operation* random =
1604 RandomUniform(shape, TF_FLOAT, func_graph.get(), s.get());
1605
1606 TF_Output inputs[] = {};
1607 TF_Output outputs[] = {{random, 0}};
1608 *func = TF_GraphToFunction(func_graph.get(), name,
1609 /*append_hash_to_fn_name=*/false, -1,
1610 /*opers=*/nullptr, 0, inputs, 1, outputs,
1611 /*output_names=*/nullptr,
1612 /*opts=*/nullptr, "", s.get());
1613 ASSERT_EQ(TF_OK, TF_GetCode(s.get())) << TF_Message(s.get());
1614 ASSERT_NE(*func, nullptr);
1615 TF_DeleteTensor(tensor_shape);
1616}
1617
1618TEST_F(CApiFunctionTest, StatefulOpDef) {
1619 DefineStatefulFunction(func_name_, &func_);

Callers 1

TEST_FFunction · 0.85

Calls 10

TF_NewGraphFunction · 0.85
TF_NewStatusFunction · 0.85
Int32TensorFunction · 0.85
TF_GraphToFunctionFunction · 0.85
TF_GetCodeFunction · 0.85
TF_MessageFunction · 0.85
TF_DeleteTensorFunction · 0.85
ConstFunction · 0.70
RandomUniformFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected