Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 24f649a

Browse files
nicolasvasilacheTheodoros Theodoridis
authored andcommitted
Move generic functions
This changeset moves a few generic functions from cuda_compilation_cache to compilation_cache
1 parent 4f90354 commit 24f649a

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

tc/core/compilation_cache.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,19 @@ bool detail::TensorInfo::operator<(const TensorInfo& t) const {
123123
strides < t.strides;
124124
}
125125

126+
bool operator==(
127+
const std::vector<const DLTensor*>& inputsTensor,
128+
const std::vector<detail::TensorInfo>& inputsInfo) {
129+
if (inputsTensor.size() != inputsInfo.size()) {
130+
return false;
131+
}
132+
CHECK(inputsTensor.size() == inputsInfo.size());
133+
for (size_t i = 0, n = inputsInfo.size(); i < n; ++i) {
134+
if (!(inputsInfo[i] == inputsTensor[i])) {
135+
return false;
136+
}
137+
}
138+
return true;
139+
}
140+
126141
} // namespace tc

tc/core/compilation_cache.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,15 @@ class CacheEntrySameKeyDifferentValue : public std::invalid_argument {
8888
: invalid_argument(what_arg) {}
8989
};
9090

91+
bool operator==(
92+
const std::vector<const DLTensor*>& inputsTensor,
93+
const std::vector<detail::TensorInfo>& inputsInfo);
94+
95+
inline std::string makeOptionsFilename(const std::string& filename) {
96+
return filename + ".options";
97+
}
98+
99+
inline std::string makeCudaFilename(const std::string& filename) {
100+
return filename + ".cuda";
101+
}
91102
} // namespace tc

tc/core/cuda/cuda_compilation_cache.cc

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,6 @@ void WriteProtobufArray(const Array& arr, Buf* buf) {
5757
}
5858
} // namespace
5959

60-
bool operator==(
61-
const std::vector<const DLTensor*>& inputsTensor,
62-
const std::vector<detail::TensorInfo>& inputsInfo) {
63-
if (inputsTensor.size() != inputsInfo.size()) {
64-
return false;
65-
}
66-
CHECK(inputsTensor.size() == inputsInfo.size());
67-
for (size_t i = 0, n = inputsInfo.size(); i < n; ++i) {
68-
if (!(inputsInfo[i] == inputsTensor[i])) {
69-
return false;
70-
}
71-
}
72-
return true;
73-
}
74-
7560
std::shared_ptr<CudaCache>& CudaCache::getGlobalSharedCache() {
7661
static std::shared_ptr<CudaCache> cudaCache_;
7762
return cudaCache_;
@@ -556,14 +541,6 @@ void removeFromCudaCacheEntriesNotInOptionsCache(
556541
cc.removeEntriesNotInOptionsCache(oc);
557542
}
558543

559-
std::string makeOptionsFilename(const std::string& filename) {
560-
return filename + ".options";
561-
}
562-
563-
std::string makeCudaFilename(const std::string& filename) {
564-
return filename + ".cuda";
565-
}
566-
567544
std::unique_ptr<CudaCache::RetrievalResult> ManualCudaCache::retrieveKernel(
568545
const std::string& id,
569546
const std::vector<const DLTensor*>& inputs,

tc/core/cuda/cuda_compilation_cache.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,6 @@ void removeFromCudaCacheEntriesNotInOptionsCache(
426426
CudaCache& cc,
427427
const OptionsCache& oc);
428428

429-
bool operator==(
430-
const std::vector<const DLTensor*>& inputsTensor,
431-
const std::vector<detail::TensorInfo>& inputsInfo);
432-
433-
std::string makeOptionsFilename(const std::string& filename);
434-
435-
std::string makeCudaFilename(const std::string& filename);
436-
437429
} // namespace tc
438430

439431
#include "tc/core/cuda/cuda_compilation_cache-inl.h"

0 commit comments

Comments
 (0)