Tensor Comprehensions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tc::CudaCache Class Reference

#include <compilation_cache.h>

Inheritance diagram for tc::CudaCache:
Collaboration diagram for tc::CudaCache:

Classes

struct  CachedEntry
 
struct  RetrievalResult
 

Public Member Functions

 CudaCache ()=default
 
 CudaCache (const CudaCacheProto &buf)
 
CudaCacheProto toProtobuf () const
 
void cacheKernel (const std::string &id, const MappingOptions &options, const std::vector< const DLTensor * > &inputs, const std::vector< const DLTensor * > &outputs, const std::string &kernelSpecializedName, const std::vector< int > &kernelParameters, const std::string &cudaSource, const Grid &grid, const Block &block)
 
std::unique_ptr< RetrievalResultretrieveKernel (const std::string &id, const MappingOptions &options, const std::vector< const DLTensor * > &inputs, const std::vector< const DLTensor * > &outputs) const
 
void removeEntriesNotInOptionsCache (const OptionsCache &oc)
 
template<typename C , typename InputTy >
auto searchKernelImpl (C &c, const std::string &id, const MappingOptions &options, const std::vector< InputTy > &inputs, const std::vector< InputTy > &outputs) -> decltype(c.searchKernel(id, options, inputs, outputs))
 
- Public Member Functions inherited from tc::Cache< CudaCache >
size_t size () const
 
void clear ()
 

Private Types

using Protobuf = CudaCacheProto
 

Private Member Functions

CachedEntrysearchKernel (const std::string &id, const MappingOptions &options, const std::vector< detail::TensorInfo > &inputs, const std::vector< detail::TensorInfo > &outputs)
 
CachedEntrysearchKernel (const std::string &id, const MappingOptions &options, const std::vector< const DLTensor * > &inputs, const std::vector< const DLTensor * > &outputs)
 
const CachedEntrysearchKernel (const std::string &id, const MappingOptions &options, const std::vector< const DLTensor * > &inputs, const std::vector< const DLTensor * > &outputs) const
 

Static Private Member Functions

static std::shared_ptr
< CudaCache > & 
getGlobalSharedCache ()
 
template<typename C , typename TensorTy >
static auto searchKernelImpl (C &c, const std::string &id, const MappingOptions &options, const std::vector< TensorTy > &inputs, const std::vector< TensorTy > &outputs) -> decltype(c.searchKernel(id, options, inputs, outputs))
 

Private Attributes

std::vector< CachedEntryentries_
 

Friends

class Cache< CudaCache >
 

Additional Inherited Members

- Static Public Member Functions inherited from tc::Cache< CudaCache >
static void enableCache ()
 
static void disableCache ()
 
static void dumpCacheToProtobuf (const std::string &filename)
 
static void loadCacheFromProtobuf (const std::string &filename)
 
static void loadCacheFromProtobuf (const Protobuf &buf)
 
static std::shared_ptr< CudaCachegetCache ()
 
static bool cacheEnabled ()
 
- Public Attributes inherited from tc::Cache< CudaCache >
int numberAttemptedRetrievals
 
int numberSuccessfulRetrievals
 
int numberCacheAttemps
 
- Protected Attributes inherited from tc::Cache< CudaCache >
std::mutex mtx_
 

Detailed Description

CudaCache stores the Cuda source of optimized kernels

Member Typedef Documentation

using tc::CudaCache::Protobuf = CudaCacheProto
private

Constructor & Destructor Documentation

tc::CudaCache::CudaCache ( )
default
tc::CudaCache::CudaCache ( const CudaCacheProto &  buf)

Member Function Documentation

void tc::CudaCache::cacheKernel ( const std::string &  id,
const MappingOptions options,
const std::vector< const DLTensor * > &  inputs,
const std::vector< const DLTensor * > &  outputs,
const std::string &  kernelSpecializedName,
const std::vector< int > &  kernelParameters,
const std::string &  cudaSource,
const Grid grid,
const Block block 
)

If op was previously cached and the inputs' shape, isl options, and the target device are the same then this is a noop Else (cudaSource, grid, block) is stored in the cache

static std::shared_ptr<CudaCache>& tc::CudaCache::getGlobalSharedCache ( )
staticprivate
void tc::CudaCache::removeEntriesNotInOptionsCache ( const OptionsCache oc)
std::unique_ptr<RetrievalResult> tc::CudaCache::retrieveKernel ( const std::string &  id,
const MappingOptions options,
const std::vector< const DLTensor * > &  inputs,
const std::vector< const DLTensor * > &  outputs 
) const

Returns the cache entry that matches op (id, isl options, target device) and inputs' shapes.

CachedEntry* tc::CudaCache::searchKernel ( const std::string &  id,
const MappingOptions options,
const std::vector< detail::TensorInfo > &  inputs,
const std::vector< detail::TensorInfo > &  outputs 
)
private

SearchKernel (through SearchKernelImpl) searches op in the cache if a cached entry that corresponds to the op's configuration (MappingOptions and TargetDevice) and the shape of inputs matches it is returned

CachedEntry* tc::CudaCache::searchKernel ( const std::string &  id,
const MappingOptions options,
const std::vector< const DLTensor * > &  inputs,
const std::vector< const DLTensor * > &  outputs 
)
private
const CachedEntry* tc::CudaCache::searchKernel ( const std::string &  id,
const MappingOptions options,
const std::vector< const DLTensor * > &  inputs,
const std::vector< const DLTensor * > &  outputs 
) const
private
template<typename C , typename InputTy >
auto tc::CudaCache::searchKernelImpl ( C &  c,
const std::string &  id,
const MappingOptions options,
const std::vector< InputTy > &  inputs,
const std::vector< InputTy > &  outputs 
) -> decltype(c.searchKernel(id, options, inputs, outputs))
template<typename C , typename TensorTy >
static auto tc::CudaCache::searchKernelImpl ( C &  c,
const std::string &  id,
const MappingOptions options,
const std::vector< TensorTy > &  inputs,
const std::vector< TensorTy > &  outputs 
) -> decltype(c.searchKernel(id, options, inputs, outputs))
staticprivate
CudaCacheProto tc::CudaCache::toProtobuf ( ) const

Friends And Related Function Documentation

friend class Cache< CudaCache >
friend

Member Data Documentation

std::vector<CachedEntry> tc::CudaCache::entries_
private

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