MCPcopy Create free account
hub / github.com/RenderKit/oidn / getByteSize

Method getByteSize

core/tensor_desc.h:133–159  ·  view source on GitHub ↗

Returns the size in bytes of the tensor

Source from the content-addressed store, hash-verified

131
132 // Returns the size in bytes of the tensor
133 oidn_inline size_t getByteSize() const
134 {
135 if (paddedDims.empty())
136 return 0;
137
138 const size_t elementSize = getDataTypeSize(dataType);
139
140 if (layout == TensorLayout::Chw8c ||
141 layout == TensorLayout::Chw16c ||
142 layout == TensorLayout::Chw32c)
143 {
144 // For blocked CHW layouts, the C planes need to be aligned
145 const size_t B = getTensorLayoutInfo(layout).blockC;
146 const size_t cByteStride = elementSize;
147 const size_t wByteStride = B * cByteStride;
148 const size_t hByteStride = size_t(getW()) * wByteStride;
149 const size_t CByteStride = round_up(size_t(getH()) * hByteStride, TensorLayoutTraitsChwBc::CByteAlignment);
150 return size_t(getPaddedC() / B) * CByteStride;
151 }
152 else
153 {
154 size_t num = 1;
155 for (size_t i = 0; i < paddedDims.size(); ++i)
156 num *= size_t(paddedDims[i]);
157 return num * elementSize;
158 }
159 }
160
161 bool operator ==(const TensorDesc& other) const
162 {

Callers

nothing calls this directly

Calls 6

getDataTypeSizeFunction · 0.85
getWFunction · 0.85
getHFunction · 0.85
sizeMethod · 0.80
round_upFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected