ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw::cker::random::SingleSampleAdapter< Generator > Class Template Reference

#include <RandomDistributions.h>

Public Types

typedef Generator::ResultElementType ResultType
 
typedef Generator::ResultElementType ResultElementType
 

Public Member Functions

PHILOX_DEVICE_INLINE SingleSampleAdapter (Generator *gen)
 
PHILOX_DEVICE_INLINE ResultType operator() ()
 
PHILOX_DEVICE_INLINE void Skip (uint64_t num_skips)
 

Static Public Attributes

static constexpr int kResultElementCount = 1
 
static constexpr int kNativeElementCount = Generator::kResultElementCount
 

Detailed Description

template<class Generator>
class nnfw::cker::random::SingleSampleAdapter< Generator >

Definition at line 315 of file RandomDistributions.h.

Member Typedef Documentation

◆ ResultElementType

template<class Generator >
typedef Generator::ResultElementType nnfw::cker::random::SingleSampleAdapter< Generator >::ResultElementType

Definition at line 323 of file RandomDistributions.h.

◆ ResultType

template<class Generator >
typedef Generator::ResultElementType nnfw::cker::random::SingleSampleAdapter< Generator >::ResultType

Definition at line 322 of file RandomDistributions.h.

Constructor & Destructor Documentation

◆ SingleSampleAdapter()

template<class Generator >
PHILOX_DEVICE_INLINE nnfw::cker::random::SingleSampleAdapter< Generator >::SingleSampleAdapter ( Generator *  gen)
inlineexplicit

Definition at line 326 of file RandomDistributions.h.

327 : generator_(gen), used_result_index_(Generator::kResultElementCount)
328 {
329 }

Member Function Documentation

◆ operator()()

template<class Generator >
PHILOX_DEVICE_INLINE ResultType nnfw::cker::random::SingleSampleAdapter< Generator >::operator() ( )
inline

Definition at line 332 of file RandomDistributions.h.

333 {
334 if (used_result_index_ == Generator::kResultElementCount)
335 {
336 unused_results_ = (*generator_)();
337 used_result_index_ = 0;
338 }
339
340 return unused_results_[used_result_index_++];
341 }

◆ Skip()

template<class Generator >
PHILOX_DEVICE_INLINE void nnfw::cker::random::SingleSampleAdapter< Generator >::Skip ( uint64_t  num_skips)
inline

Definition at line 344 of file RandomDistributions.h.

345 {
346 if (!num_skips)
347 {
348 return;
349 }
350 int num_unused_results = kNativeElementCount - used_result_index_;
351 if (num_skips <= num_unused_results)
352 {
353 used_result_index_ += num_skips;
354 return;
355 }
356 num_skips -= num_unused_results;
357 used_result_index_ = kNativeElementCount;
358 SkipFromGenerator(num_skips / kNativeElementCount);
359 num_skips = num_skips % kNativeElementCount;
360 if (num_skips)
361 {
362 unused_results_ = (*generator_)();
363 used_result_index_ = num_skips;
364 }
365 }

References nnfw::cker::random::SingleSampleAdapter< Generator >::kNativeElementCount.

Field Documentation

◆ kNativeElementCount

template<class Generator >
constexpr int nnfw::cker::random::SingleSampleAdapter< Generator >::kNativeElementCount = Generator::kResultElementCount
staticconstexpr

◆ kResultElementCount

template<class Generator >
constexpr int nnfw::cker::random::SingleSampleAdapter< Generator >::kResultElementCount = 1
staticconstexpr

Definition at line 319 of file RandomDistributions.h.


The documentation for this class was generated from the following file: