MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / OffsetTo

Method OffsetTo

oneflow/core/register/tensor_slice_view.cpp:100–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98size_t TensorSliceView::NumAxes() const { return range_vec_.size(); }
99
100NdIndex TensorSliceView::OffsetTo(const TensorSliceView& other) const {
101 CHECK_EQ(other.NumAxes(), NumAxes());
102 DimVector indices_vec(range_vec_.size());
103 std::transform(range_vec_.cbegin(), range_vec_.cend(), other.range_vec_.cbegin(),
104 indices_vec.begin(),
105 [](const Range& lhs, const Range& rhs) { return lhs.begin() - rhs.begin(); });
106 return NdIndex(indices_vec);
107}
108
109void TensorSliceView::ToProto(TensorSliceViewProto* proto) const {
110 for (const Range& range : range_vec_) { range.ToProto(proto->mutable_dim()->Add()); }

Callers 1

TensorSliceCopierMethod · 0.80

Calls 7

NdIndexClass · 0.85
cbeginMethod · 0.80
cendMethod · 0.80
NumAxesFunction · 0.50
NumAxesMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected