| 1810 | // when the tensor of `sizes` is available. |
| 1811 | template <typename T> |
| 1812 | Status SliceHelper(InferenceContext* c, ShapeHandle begin_value, |
| 1813 | const Tensor* sizes_value, |
| 1814 | std::vector<DimensionHandle>* dims) { |
| 1815 | auto sizes_vec = sizes_value->vec<T>(); |
| 1816 | for (int i = 0; i < sizes_value->NumElements(); ++i) { |
| 1817 | DimensionHandle dim = c->Dim(c->input(0), i); |
| 1818 | if (sizes_vec(i) != -1) { |
| 1819 | auto dim_val = c->Value(dim); |
| 1820 | if (sizes_vec(i) < 0) { |
| 1821 | return errors::InvalidArgument( |
| 1822 | "Out of bounds slicing on dimension ", i, " of length ", dim_val, |
| 1823 | ": sizes vector cannot be < -1, but was ", sizes_vec(i)); |
| 1824 | } |
| 1825 | |
| 1826 | dims->emplace_back(c->MakeDim(sizes_vec(i))); |
| 1827 | } else { |
| 1828 | DimensionHandle result; |
| 1829 | TF_RETURN_IF_ERROR(c->Subtract(dim, c->Dim(begin_value, i), &result)); |
| 1830 | dims->emplace_back(result); |
| 1831 | } |
| 1832 | } |
| 1833 | |
| 1834 | return Status::OK(); |
| 1835 | } |
| 1836 | } // namespace |
| 1837 | |
| 1838 | Status SliceShape(InferenceContext* c) { |
nothing calls this directly
no test coverage detected