| 1593 | } |
| 1594 | |
| 1595 | void 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 | |
| 1618 | TEST_F(CApiFunctionTest, StatefulOpDef) { |
| 1619 | DefineStatefulFunction(func_name_, &func_); |
no test coverage detected