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

Function SliceHelper

tensorflow/core/framework/common_shape_fns.cc:1812–1835  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1810// when the tensor of `sizes` is available.
1811template <typename T>
1812Status 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
1838Status SliceShape(InferenceContext* c) {

Callers

nothing calls this directly

Calls 8

InvalidArgumentFunction · 0.85
SubtractMethod · 0.80
NumElementsMethod · 0.45
DimMethod · 0.45
inputMethod · 0.45
ValueMethod · 0.45
emplace_backMethod · 0.45
MakeDimMethod · 0.45

Tested by

no test coverage detected