| 1607 | } |
| 1608 | |
| 1609 | PyObject* TFE_Py_TapeSetShouldRecord(PyObject* tensors) { |
| 1610 | if (!TapeCouldPossiblyRecord(tensors)) { |
| 1611 | Py_RETURN_FALSE; |
| 1612 | } |
| 1613 | // TODO(apassos) consider not building a list and changing the API to check |
| 1614 | // each tensor individually. |
| 1615 | std::vector<tensorflow::int64> tensor_ids; |
| 1616 | std::vector<tensorflow::DataType> dtypes; |
| 1617 | if (!TensorShapesAndDtypes(tensors, &tensor_ids, &dtypes)) { |
| 1618 | return nullptr; |
| 1619 | } |
| 1620 | auto tape_set = *GetTapeSet(); |
| 1621 | for (TFE_Py_Tape* tape : tape_set) { |
| 1622 | if (tape->tape->ShouldRecord(tensor_ids, dtypes)) { |
| 1623 | Py_RETURN_TRUE; |
| 1624 | } |
| 1625 | } |
| 1626 | auto forward_accumulators = *GetAccumulatorSet(); |
| 1627 | for (TFE_Py_ForwardAccumulator* accumulator : forward_accumulators) { |
| 1628 | if (accumulator->accumulator->ShouldRecord(tensor_ids, dtypes)) { |
| 1629 | Py_RETURN_TRUE; |
| 1630 | } |
| 1631 | } |
| 1632 | |
| 1633 | Py_RETURN_FALSE; |
| 1634 | } |
| 1635 | |
| 1636 | PyObject* TFE_Py_TapeSetPossibleGradientTypes(PyObject* tensors) { |
| 1637 | if (!TapeCouldPossiblyRecord(tensors)) { |
nothing calls this directly
no test coverage detected