Run the graph and ensure that the gradient values are as expected.
| 1573 | |
| 1574 | // Run the graph and ensure that the gradient values are as expected. |
| 1575 | void RunGraphsAndCompareOutputs(TF_Output* grad_outputs, |
| 1576 | TF_Output* expected_grad_outputs) { |
| 1577 | std::unique_ptr<CSession> csession(new CSession(graph_, s_)); |
| 1578 | std::unique_ptr<CSession> expected_csession( |
| 1579 | new CSession(expected_graph_, s_)); |
| 1580 | |
| 1581 | std::vector<TF_Output> grad_outputs_vec; |
| 1582 | grad_outputs_vec.assign(grad_outputs, grad_outputs + 2); |
| 1583 | csession->SetOutputs(grad_outputs_vec); |
| 1584 | csession->Run(s_); |
| 1585 | ASSERT_EQ(TF_OK, TF_GetCode(s_)) << TF_Message(s_); |
| 1586 | TF_Tensor* out0 = csession->output_tensor(0); |
| 1587 | TF_Tensor* out1 = csession->output_tensor(1); |
| 1588 | |
| 1589 | std::vector<TF_Output> expected_grad_outputs_vec; |
| 1590 | expected_grad_outputs_vec.assign(expected_grad_outputs, |
| 1591 | expected_grad_outputs + 2); |
| 1592 | expected_csession->SetOutputs(expected_grad_outputs_vec); |
| 1593 | expected_csession->Run(s_); |
| 1594 | ASSERT_EQ(TF_OK, TF_GetCode(s_)) << TF_Message(s_); |
| 1595 | TF_Tensor* expected_out0 = expected_csession->output_tensor(0); |
| 1596 | TF_Tensor* expected_out1 = expected_csession->output_tensor(1); |
| 1597 | |
| 1598 | CompareTensors(out0, expected_out0); |
| 1599 | CompareTensors(out1, expected_out1); |
| 1600 | } |
| 1601 | |
| 1602 | void CompareTensors(TF_Tensor* a, TF_Tensor* b) { |
| 1603 | float* a_data = static_cast<float*>(TF_TensorData(a)); |
nothing calls this directly
no test coverage detected