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

Commit c1128d4

Browse files
author
Theodoros Theodoridis
committed
Replace all occurences of CHECK_* with TC_CHECK_*
1 parent af1eeaa commit c1128d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+385
-320
lines changed

tc/aten/aten_autotuner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace aten {
3535
* auto best = tuner.tune("tc_function_name", inputs, baseOption, cacheFn)
3636
*
3737
* The best options may then be used to compile an executor and run.
38-
* CHECK_GT(best.size(), 0);
38+
* TC_CHECK_GT(best.size(), 0);
3939
* auto pExecutor = compile(tc, "tc_function_name", inputs, best[0]);
4040
* auto outputs = prepareOutputs(tc, "tc_function_name", inputs);
4141
* // memoize the executor and outputs if needed

tc/aten/aten_compiler-inl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <vector>
2121

2222
#include "tc/aten/aten.h"
23+
#include "tc/core/check.h"
2324
#include "tc/core/compiler.h"
2425
#include "tc/core/tc_executor.h"
2526
#include "tc/core/tensor.h"
@@ -71,7 +72,7 @@ void uncheckedRun(
7172
const Executor& executor,
7273
const std::vector<at::Tensor>& inputs,
7374
std::vector<at::Tensor>& outputs) {
74-
CHECK_GE(outputs.size(), 1u);
75+
TC_CHECK_GE(outputs.size(), 1u);
7576
std::vector<const void*> rawInputs(inputs.size(), nullptr);
7677
std::vector<void*> rawOutputs(outputs.size(), nullptr);
7778
for (size_t i = 0; i < inputs.size(); ++i) {

tc/aten/aten_compiler.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <vector>
2121

2222
#include "tc/aten/aten.h"
23+
#include "tc/core/check.h"
2324
#include "tc/core/compiler.h"
2425
#include "tc/core/tc_executor.h"
2526
#include "tc/core/tensor.h"
@@ -32,7 +33,7 @@ std::vector<tc::DLTensorUPtr> inferOutputTensorInfo(
3233
const std::vector<at::Tensor>& inputs) {
3334
auto parsedTcs = tc::detail::parse(tc);
3435
if (parsedTcs.count(entryPoint) != 1u) {
35-
CHECK_GE(parsedTcs.size(), 1u)
36+
TC_CHECK_GE(parsedTcs.size(), 1u)
3637
<< "No TC was parsed, should have thrown earlier";
3738
throw lang::ErrorReport(parsedTcs.begin()->second)
3839
<< "\nattempting to access undefined entryPoint: " << entryPoint;
@@ -51,7 +52,7 @@ std::vector<at::Tensor> prepareOutputs(
5152
if (outTensorInfo.size() == 0) {
5253
return outputs;
5354
}
54-
CHECK_GE(inputs.size(), 1u)
55+
TC_CHECK_GE(inputs.size(), 1u)
5556
<< "NYI: Need >= 1 input tensors to determine "
5657
<< "backend and prepare ATen outputs. Add an overload with just an ATen "
5758
<< "backend";

tc/autotuner/autotuner-inl.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <glog/stl_logging.h>
2222

2323
#include "tc/autotuner/utils.h"
24+
#include "tc/core/check.h"
2425
#include "tc/core/compiler.h"
2526
#include "tc/core/flags.h"
2627
#include "tc/core/scope_guard.h"
@@ -123,9 +124,9 @@ void TuningHarness<Backend>::doEvaluate(
123124
size_t populationSize,
124125
Printer& printer) {
125126
typename Backend::WithDevice wd(device);
126-
CHECK_EQ(inputs_.count(device), 1u);
127+
TC_CHECK_EQ(inputs_.count(device), 1u);
127128
auto& inputs = inputs_.at(device);
128-
CHECK_EQ(outputs_.count(device), 1u);
129+
TC_CHECK_EQ(outputs_.count(device), 1u);
129130
auto& outputs = outputs_.at(device);
130131

131132
while (true) {
@@ -154,7 +155,7 @@ void TuningHarness<Backend>::doEvaluate(
154155
if (!pExecutor.get()) {
155156
// If I popped an empty executor then compilation didn't go as
156157
// planned, skip it.
157-
CHECK(pConf->invalid);
158+
TC_CHECK(pConf->invalid);
158159
continue;
159160
}
160161

@@ -243,8 +244,8 @@ void TuningHarness<Backend>::runOneIteration(
243244
size_t iteration) {
244245
// Define tensors per device once globally
245246
auto devices = detail::parseDevices<Backend>(FLAGS_tuner_devices);
246-
CHECK(executors_.empty());
247-
CHECK(configurations_.empty());
247+
TC_CHECK(executors_.empty());
248+
TC_CHECK(configurations_.empty());
248249

249250
{
250251
// Initialize for this round
@@ -375,7 +376,7 @@ std::vector<size_t> inputDivisorsAndPowers2(
375376
}
376377

377378
size_t largestDim(const std::vector<const DLConstTensor*>& inputs) {
378-
CHECK_GE(inputs.size(), 1u);
379+
TC_CHECK_GE(inputs.size(), 1u);
379380
auto maxElement = std::max_element(
380381
inputs.begin(),
381382
inputs.end(),
@@ -389,7 +390,7 @@ size_t largestDim(const std::vector<const DLConstTensor*>& inputs) {
389390
void setupTuningParameters(
390391
const std::vector<const DLConstTensor*>& inputs,
391392
TuningConfiguration& configuration) {
392-
CHECK_GE(inputs.size(), 1u);
393+
TC_CHECK_GE(inputs.size(), 1u);
393394
auto range = inputDivisorsAndPowers2(inputs);
394395
// 0 is a valid tiling annotation and signals no tiling of that dimension
395396
// 0 is not a valid block / grid annotation
@@ -419,12 +420,12 @@ Autotuner<Backend, SearchStrategy>::tune(
419420
const std::string& cacheFileName,
420421
const TuningParameterFixer& fixedParams) {
421422
std::map<std::string, lang::TreeRef> tcEntryPointMap(tc::detail::parse(tc));
422-
CHECK_EQ(tcEntryPointMap.count(tcEntryPoint), 1u)
423+
TC_CHECK_EQ(tcEntryPointMap.count(tcEntryPoint), 1u)
423424
<< "Error looking up " << tcEntryPoint;
424425

425426
// Initialize a model configuration
426427
TuningConfiguration modelConfiguration;
427-
CHECK_GE(inputs.size(), 1u);
428+
TC_CHECK_GE(inputs.size(), 1u);
428429
setupTuningParameters(inputs.begin()->second, modelConfiguration);
429430
modelConfiguration.fixParameters(fixedParams);
430431

tc/autotuner/genetic_search.cc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <random>
2020
#include <sstream>
2121

22+
#include "tc/core/check.h"
23+
2224
namespace tc {
2325
namespace autotune {
2426

@@ -130,13 +132,13 @@ void dropInvalidConfigurations(GeneticSearch::Population& population) {
130132

131133
} // namespace
132134

133-
#define VALIDATE() \
134-
CHECK_LT(numberElites, maxPopulationSize); \
135-
CHECK(mutationRate >= 0 and mutationRate <= 100) \
136-
<< "the mutation rate (" << mutationRate \
137-
<< ") should be in the [0,100] interval"; \
138-
CHECK(crossOverRate >= 0 and crossOverRate <= 100) \
139-
<< "the crossover (" << crossOverRate \
135+
#define VALIDATE() \
136+
TC_CHECK_LT(numberElites, maxPopulationSize); \
137+
TC_CHECK(mutationRate >= 0 and mutationRate <= 100) \
138+
<< "the mutation rate (" << mutationRate \
139+
<< ") should be in the [0,100] interval"; \
140+
TC_CHECK(crossOverRate >= 0 and crossOverRate <= 100) \
141+
<< "the crossover (" << crossOverRate \
140142
<< ") rate should be in the [0,100] interval";
141143

142144
namespace {
@@ -170,7 +172,7 @@ GeneticSearch::GeneticSearch(
170172
rng{std::random_device{}()} {
171173
restoreRngState(rng);
172174
VALIDATE();
173-
CHECK(not confs.empty()) << "empty set of predefined configurations";
175+
TC_CHECK(not confs.empty()) << "empty set of predefined configurations";
174176

175177
population.reserve(populationSize);
176178
size_t size = 0;
@@ -296,7 +298,7 @@ void GeneticSearch::updateParameters() {
296298
make_unique<CandidateConfiguration>(lastBestConf));
297299
}
298300
// Don't lose the first one which was the best from before
299-
CHECK_LT(0u, population.size());
301+
TC_CHECK_LT(0u, population.size());
300302
randomizePopulation(population.begin() + 1, population.end(), rng);
301303
return;
302304
}

tc/autotuner/options_cache-inl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <llvm/ADT/Optional.h>
2828

29+
#include "tc/core/check.h"
2930
#include "tc/core/tensor.h"
3031
#include "tc/core/utils/math.h"
3132
#include "tc/core/utils/time.h"
@@ -307,7 +308,7 @@ template <typename Backend>
307308
void OptionsCache<Backend>::fromProtobuf(
308309
const typename Backend::OptionsCacheProtoType& proto) {
309310
std::lock_guard<std::mutex> lock(mutex);
310-
CHECK_EQ(proto.keys().size(), proto.values().size());
311+
TC_CHECK_EQ(proto.keys().size(), proto.values().size());
311312
for (int i = 0; i < proto.keys().size(); ++i) {
312313
OptionsCacheKey key(OptionsCacheKey::fromProtobuf(proto.keys().Get(i)));
313314
OptionsCacheValue<Backend> value(

tc/autotuner/parameters.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <sstream>
2424
#include <typeinfo>
2525

26+
#include "tc/core/check.h"
27+
2628
namespace tc {
2729
namespace autotune {
2830

@@ -97,7 +99,7 @@ RangeParameter& RangeParameter::operator=(const RangeParameter& other) {
9799
}
98100

99101
void BoolParameter::selectOption(size_t idx) {
100-
CHECK_LE(idx, 1u);
102+
TC_CHECK_LE(idx, 1u);
101103
selectValue(idx);
102104
}
103105

@@ -106,7 +108,7 @@ void BoolParameter::selectValue(bool val) {
106108
}
107109

108110
void RangeParameter::selectOption(size_t idx) {
109-
CHECK_LE(idx, values_.size());
111+
TC_CHECK_LE(idx, values_.size());
110112
selected_ = idx;
111113
}
112114

@@ -124,8 +126,8 @@ void RangeParameter::selectFromValue(size_t value) {
124126
}
125127

126128
void ParameterView::overwrite(const ParameterView& pv) {
127-
CHECK_EQ(rangePtr == nullptr, pv.rangePtr == nullptr);
128-
CHECK_EQ(boolPtr == nullptr, pv.boolPtr == nullptr);
129+
TC_CHECK_EQ(rangePtr == nullptr, pv.rangePtr == nullptr);
130+
TC_CHECK_EQ(boolPtr == nullptr, pv.boolPtr == nullptr);
129131
if (rangePtr) {
130132
*rangePtr = *pv.rangePtr;
131133
} else {
@@ -134,7 +136,7 @@ void ParameterView::overwrite(const ParameterView& pv) {
134136
}
135137

136138
bool ParameterView::isForced() const {
137-
CHECK((rangePtr == nullptr) xor (boolPtr == nullptr));
139+
TC_CHECK((rangePtr == nullptr) xor (boolPtr == nullptr));
138140
if (rangePtr) {
139141
return rangePtr->fixedValue_.hasValue();
140142
} else {
@@ -143,7 +145,7 @@ bool ParameterView::isForced() const {
143145
}
144146

145147
size_t ParameterView::numberOptions() const {
146-
CHECK((rangePtr == nullptr) xor (boolPtr == nullptr));
148+
TC_CHECK((rangePtr == nullptr) xor (boolPtr == nullptr));
147149
if (rangePtr) {
148150
return rangePtr->numberOptions();
149151
} else {
@@ -152,7 +154,7 @@ size_t ParameterView::numberOptions() const {
152154
}
153155

154156
void ParameterView::selectOption(size_t idx) {
155-
CHECK((rangePtr == nullptr) xor (boolPtr == nullptr));
157+
TC_CHECK((rangePtr == nullptr) xor (boolPtr == nullptr));
156158
if (rangePtr) {
157159
return rangePtr->selectOption(idx);
158160
} else {
@@ -361,8 +363,8 @@ TuningConfiguration::TuningConfiguration()
361363
case 1:
362364
return b0v;
363365
default:
364-
CHECK(false) << "Must have (1-3) block dims, got: "
365-
<< conf.blockParams.numberDims.value();
366+
TC_CHECK(false) << "Must have (1-3) block dims, got: "
367+
<< conf.blockParams.numberDims.value();
366368
}
367369
return b0v;
368370
}();
@@ -459,7 +461,7 @@ void CudaDimParameters::setRange(
459461
namespace {
460462
template <typename Params, typename View>
461463
void fromMappingOptions(Params& params, const View& options) {
462-
CHECK_LE(options.size(), params.dims.size());
464+
TC_CHECK_LE(options.size(), params.dims.size());
463465
params.numberDims.selectFromValue(options.size());
464466
for (size_t i = 0; i < options.size(); ++i) {
465467
params.dims[i].selectFromValue(options[i]);

tc/benchmarks/MLP_model.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "tc/aten/aten.h"
2525

2626
#include "tc/aten/aten_compiler.h"
27+
#include "tc/core/check.h"
2728
#include "tc/core/cuda/cuda_mapping_options.h"
2829

2930
#include "../test/caffe2/cuda/test_harness.h"
@@ -150,7 +151,7 @@ void ProductionModel::run1LUT(
150151
uint32_t E1,
151152
const tc::CudaMappingOptions& options,
152153
bool use_flags) {
153-
CHECK_LT(0, E1);
154+
TC_CHECK_LT(0, E1);
154155

155156
// This test uses an c2 OpTester because we need to run the C2 reference
156157
// implementation for TcLUTOp.
@@ -238,8 +239,8 @@ void ProductionModel::run2LUT(
238239
uint32_t E2,
239240
const tc::CudaMappingOptions& options,
240241
bool use_flags) {
241-
CHECK_LT(0, E1);
242-
CHECK_LT(0, E2);
242+
TC_CHECK_LT(0, E1);
243+
TC_CHECK_LT(0, E2);
243244

244245
auto ws_init_func = [=](Workspace& w) {
245246
AddDeterministicallyRandomInput<caffe2::CUDABackend, float>(

tc/benchmarks/benchmark_fixture.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "tc/aten/aten_compiler.h"
3030
#include "tc/autotuner/genetic_search.h"
3131
#include "tc/autotuner/utils.h"
32+
#include "tc/core/check.h"
3233
#include "tc/core/cuda/cuda.h"
3334
#include "tc/core/cuda/cuda_mapping_options.h"
3435
#include "tc/core/cuda/cuda_rtc.h"
@@ -65,33 +66,33 @@ struct Benchmark : public ::testing::Test {
6566
void SetUp() {
6667
if (!FLAGS_disable_version_checks) {
6768
auto cudnnVersion = cudnnGetVersion();
68-
CHECK_LE(6021, cudnnVersion)
69+
TC_CHECK_LE(6021, cudnnVersion)
6970
<< "[CUDNN][VERSION] Enforce version compatibility check";
7071

7172
auto cudaRtVersion = cudnnGetCudartVersion();
72-
CHECK_LE(8000, cudaRtVersion)
73+
TC_CHECK_LE(8000, cudaRtVersion)
7374
<< "[CUDART][VERSION] Enforce version compatibility check";
7475

7576
int cublasVersion;
7677
cublasHandle_t handle;
7778
TC_CUDA_CUBLAS_ENFORCE(cublasCreate_v2(&handle));
7879
TC_CUDA_CUBLAS_ENFORCE(cublasGetVersion_v2(handle, &cublasVersion));
79-
CHECK_LE(8000, cublasVersion)
80+
TC_CHECK_LE(8000, cublasVersion)
8081
<< "[CUBLAS][VERSION] Enforce version compatibility check";
8182
tc::ScopeGuard sg(
8283
[&handle]() { TC_CUDA_CUBLAS_ENFORCE(cublasDestroy_v2(handle)); });
8384

8485
int cudaRuntimeVersion;
8586
TC_CUDA_RUNTIMEAPI_ENFORCE(cudaRuntimeGetVersion(&cudaRuntimeVersion));
86-
CHECK_LE(8000, cudaRuntimeVersion)
87+
TC_CHECK_LE(8000, cudaRuntimeVersion)
8788
<< "[CUDA RUNTIME][VERSION] Enforce version compatibility check";
8889

8990
int nvrtcVersionMajor;
9091
int nvrtcVersionMinor;
9192
TC_NVRTC_CHECK(nvrtcVersion(&nvrtcVersionMajor, &nvrtcVersionMinor));
92-
CHECK_LE(8, nvrtcVersionMajor)
93+
TC_CHECK_LE(8, nvrtcVersionMajor)
9394
<< "[NVRTC][MAJOR][VERSION] Enforce version compatibility check";
94-
CHECK_LE(0, nvrtcVersionMinor)
95+
TC_CHECK_LE(0, nvrtcVersionMinor)
9596
<< "[NVRTC][MINOR][VERSION] Enforce version compatibility check";
9697
}
9798
}
@@ -261,7 +262,7 @@ struct Benchmark : public ::testing::Test {
261262
1);
262263
}();
263264

264-
CHECK_GT(mappingOptions.size(), 0)
265+
TC_CHECK_GT(mappingOptions.size(), 0)
265266
<< "No mapping options for " << tc << " in loaded cache";
266267
auto pExecutor =
267268
tc::aten::compile<tc::CudaBackend>(tc, name, inputs, mappingOptions[0]);
@@ -361,8 +362,8 @@ struct Benchmark : public ::testing::Test {
361362
auto bestOptions = [&]() {
362363
auto options = geneticAutotuneATen.tune(
363364
kernelName, inputs, baseMapping, cacheFilename, fixedParams);
364-
CHECK_GE(options.size(), 1u) << "Benchmark mode: at least one "
365-
<< "options expected";
365+
TC_CHECK_GE(options.size(), 1u) << "Benchmark mode: at least one "
366+
<< "options expected";
366367
return options[0];
367368
}();
368369

tc/c2/convolution_op.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <vector>
2020

2121
#include "tc/c2/tc_op.h"
22+
#include "tc/core/check.h"
2223
#include "tc/library/convolution.h"
2324

2425
namespace caffe2 {
@@ -58,7 +59,7 @@ class TcConvolutionOp : public TcOp<T, Context, Engine> {
5859
padR = OperatorBase::GetSingleArgument<int>("pad_r", 0);
5960
}
6061

61-
CHECK(padT == 0 && padL == 0 && padB == 0 && padR == 0)
62+
TC_CHECK(padT == 0 && padL == 0 && padB == 0 && padR == 0)
6263
<< "NYI: padding larger than 0";
6364

6465
this->tc_ = tc::makeConvolution2DTc(strideH, strideW);

0 commit comments

Comments
 (0)