MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / sub

Method sub

src/core/impl/tensor.cpp:242–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240
241template <class Trait>
242TensorStorage<Trait> TensorStorage<Trait>::sub(ptrdiff_t offset) const {
243 ptr(); // apply lazy resize
244 ptrdiff_t toff = offset + m_offset;
245 if (offset == static_cast<ptrdiff_t>(m_size)) {
246 return {false, m_comp_node, 0, 0, 0, RawStorage{}};
247 }
248 mgb_assert(
249 toff >= 0 && offset < static_cast<ptrdiff_t>(m_size),
250 "bad subtensor: offset=%td m_offset=%zu m_size=%zu", offset, m_offset,
251 m_size);
252 return {false,
253 m_comp_node,
254 m_size - offset,
255 m_capacity - offset,
256 static_cast<size_t>(toff),
257 m_data,
258 m_ref_ptr};
259}
260
261template <class Trait>
262dt_byte* TensorStorage<Trait>::apply_lazy_and_get_ptr() {

Callers 15

process_fileFunction · 0.45
sliceMethod · 0.45
applyMethod · 0.45
run_noncontig_testFunction · 0.45
TESTFunction · 0.45
run_negative_index_testFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
tensor.cppFile · 0.45
defrag_implMethod · 0.45

Calls

no outgoing calls

Tested by 11

run_noncontig_testFunction · 0.36
TESTFunction · 0.36
run_negative_index_testFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
reduce_rawFunction · 0.36
TESTFunction · 0.36