MCPcopy Create free account
hub / github.com/NVIDIA/cutlass / const_reference

Class const_reference

include/cutlass/array_subbyte.h:174–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172
173 /// Reference object extracts sub-byte items
174 class const_reference {
175
176 /// Pointer to storage element
177 Storage const *ptr_{nullptr};
178
179 /// Index into elements packed into Storage object
180 int idx_{0};
181
182 public:
183
184 const_reference() = default;
185
186 /// Ctor
187 CUTLASS_HOST_DEVICE
188 const_reference(Storage const *ptr, int idx = 0): ptr_(ptr), idx_(idx) { }
189
190 CUTLASS_HOST_DEVICE
191 const T get() const {
192 Storage item = (*ptr_ >> (idx_ * sizeof_bits<T>::value)) & kMask;
193 return reinterpret_cast<T const &>(item);
194 }
195
196 /// Extract
197 CUTLASS_HOST_DEVICE
198 operator T() const {
199 Storage item = Storage(Storage(*ptr_ >> Storage(idx_ * sizeof_bits<T>::value)) & kMask);
200 return reinterpret_cast<T const &>(item);
201 }
202
203 /// Explicit cast to int
204 CUTLASS_HOST_DEVICE
205 explicit operator int() const {
206 return int(get());
207 }
208
209 /// Explicit cast to float
210 CUTLASS_HOST_DEVICE
211 explicit operator float() const {
212 return float(get());
213 }
214 };
215
216 //
217 // Iterators

Callers 3

operator*Method · 0.85
atMethod · 0.85
backMethod · 0.85

Calls 1

getFunction · 0.70

Tested by

no test coverage detected