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

Commit c751078

Browse files
Theodoros Theodoridisnicolasvasilache
authored andcommitted
Replace all occurences of CHECK_* with TC_CHECK_*
1 parent 973da6a commit c751078

Some content is hidden

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

68 files changed

+376
-316
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"
@@ -127,9 +128,9 @@ void TuningHarness<Backend>::doEvaluate(
127128
size_t populationSize,
128129
Printer& printer) {
129130
typename Backend::WithDevice wd(device);
130-
CHECK_EQ(inputs_.count(device), 1u);
131+
TC_CHECK_EQ(inputs_.count(device), 1u);
131132
auto& inputs = inputs_.at(device);
132-
CHECK_EQ(outputs_.count(device), 1u);
133+
TC_CHECK_EQ(outputs_.count(device), 1u);
133134
auto& outputs = outputs_.at(device);
134135

135136
while (true) {
@@ -158,7 +159,7 @@ void TuningHarness<Backend>::doEvaluate(
158159
if (!pExecutor.get()) {
159160
// If I popped an empty executor then compilation didn't go as
160161
// planned, skip it.
161-
CHECK(pConf->invalid);
162+
TC_CHECK(pConf->invalid);
162163
continue;
163164
}
164165

@@ -252,8 +253,8 @@ void TuningHarness<Backend>::runOneIteration(
252253
size_t iteration) {
253254
// Define tensors per device once globally
254255
auto devices = detail::parseDevices<Backend>(FLAGS_tuner_devices);
255-
CHECK(executors_.empty());
256-
CHECK(configurations_.empty());
256+
TC_CHECK(executors_.empty());
257+
TC_CHECK(configurations_.empty());
257258

258259
{
259260
// Initialize for this round
@@ -384,7 +385,7 @@ std::vector<size_t> inputDivisorsAndPowers2(
384385
}
385386

386387
size_t largestDim(const std::vector<const DLConstTensor*>& inputs) {
387-
CHECK_GE(inputs.size(), 1u);
388+
TC_CHECK_GE(inputs.size(), 1u);
388389
auto maxElement = std::max_element(
389390
inputs.begin(),
390391
inputs.end(),
@@ -398,7 +399,7 @@ size_t largestDim(const std::vector<const DLConstTensor*>& inputs) {
398399
void setupTuningParameters(
399400
const std::vector<const DLConstTensor*>& inputs,
400401
TuningConfiguration& configuration) {
401-
CHECK_GE(inputs.size(), 1u);
402+
TC_CHECK_GE(inputs.size(), 1u);
402403
auto range = inputDivisorsAndPowers2(inputs);
403404
// 0 is a valid tiling annotation and signals no tiling of that dimension
404405
// 0 is not a valid block / grid annotation
@@ -428,12 +429,12 @@ Autotuner<Backend, SearchStrategy>::tune(
428429
const std::string& cacheFileName,
429430
const TuningParameterFixer& fixedParams) {
430431
std::map<std::string, lang::TreeRef> tcEntryPointMap(tc::detail::parse(tc));
431-
CHECK_EQ(tcEntryPointMap.count(tcEntryPoint), 1u)
432+
TC_CHECK_EQ(tcEntryPointMap.count(tcEntryPoint), 1u)
432433
<< "Error looking up " << tcEntryPoint;
433434

434435
// Initialize a model configuration
435436
TuningConfiguration modelConfiguration;
436-
CHECK_GE(inputs.size(), 1u);
437+
TC_CHECK_GE(inputs.size(), 1u);
437438
setupTuningParameters(inputs.begin()->second, modelConfiguration);
438439
modelConfiguration.fixParameters(fixedParams);
439440

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: 11 additions & 9 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
}();

tc/benchmarks/MLP_model.cc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "tc/aten/aten.h"
2727

2828
#include "tc/aten/aten_compiler.h"
29+
#include "tc/core/check.h"
2930
#include "tc/core/cuda/cuda_mapping_options.h"
3031

3132
#include "../test/caffe2/cuda/test_harness.h"
@@ -200,8 +201,6 @@ class ProductionModel : public Benchmark {
200201
};
201202

202203
void ProductionModel::run1LUT(const tc::CudaMappingOptions& options) {
203-
CHECK_LT(0, E1);
204-
205204
// This test uses an c2 OpTester because we need to run the C2 reference
206205
// implementation for TcLUTOp.
207206
auto ws_init_func = [=](Workspace& w) {
@@ -266,7 +265,7 @@ def _1LUT(float(E1, D) LUT1, int32(B, L1) I1) -> (O1) {
266265
inputs,
267266
options,
268267
check_fun);
269-
CHECK_GE(bestOptions.size(), 1u);
268+
TC_CHECK_GE(bestOptions.size(), 1u);
270269
}
271270
Check(tc, "_1LUT", options, inputs, check_fun);
272271
}
@@ -294,9 +293,8 @@ void ProductionModel::runATen1LUT() {
294293
}
295294

296295
void ProductionModel::run2LUT(const tc::CudaMappingOptions& options) {
297-
CHECK_LT(0, E1);
298-
CHECK_LT(0, E2);
299-
296+
TC_CHECK_LT(0, E1);
297+
TC_CHECK_LT(0, E2);
300298
auto ws_init_func = [=](Workspace& w) {
301299
AddDeterministicallyRandomInput<caffe2::CUDABackend, float>(
302300
w, {E1, D}, "LUT1");
@@ -385,7 +383,7 @@ def _2LUT(float(E1, D) LUT1, int32(B, L1) I1, float(E2, D) LUT2, int32(B, L2) I2
385383
inputs,
386384
options,
387385
check_fun);
388-
CHECK_GE(bestOptions.size(), 1u);
386+
TC_CHECK_GE(bestOptions.size(), 1u);
389387
}
390388
Check(tc, "_2LUT", bestOptions[0], inputs, check_fun);
391389
}
@@ -454,7 +452,7 @@ def _C3(float(B,WX) I, float(WY, WX) W) -> (C3) {
454452
inputs,
455453
options,
456454
check_fun);
457-
CHECK_GE(bestOptions.size(), 1u);
455+
TC_CHECK_GE(bestOptions.size(), 1u);
458456
}
459457
Check(tc, "_C3", bestOptions[0], inputs, check_fun);
460458
}
@@ -519,7 +517,7 @@ def mlp1(float(B,M) I, float(M, N) W1, float(N) B1) -> (O1) {
519517
inputs,
520518
options,
521519
check_fun);
522-
CHECK_GE(bestOptions.size(), 1u);
520+
TC_CHECK_GE(bestOptions.size(), 1u);
523521
}
524522
Check(tc, "mlp1", bestOptions[0], inputs, check_fun);
525523
}
@@ -602,7 +600,7 @@ def mlp3(float(B,N) I, float(O,N) W2, float(O) B2, float(P,O) W3, float(P) B3,
602600
inputs,
603601
options,
604602
check_fun);
605-
CHECK_GE(bestOptions.size(), 1u);
603+
TC_CHECK_GE(bestOptions.size(), 1u);
606604
}
607605
Check(tc, "mlp3", bestOptions[0], inputs, check_fun);
608606
}

tc/benchmarks/benchmark_fixture.h

Lines changed: 9 additions & 8 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
}
@@ -191,8 +192,8 @@ struct Benchmark : public ::testing::Test {
191192
auto bestOptions = [&]() {
192193
auto options = geneticAutotuneATen.tune(
193194
kernelName, inputs, baseMapping, cacheFilename, fixedParams);
194-
CHECK_GE(options.size(), 1u) << "Benchmark mode: at least one "
195-
<< "options expected";
195+
TC_CHECK_GE(options.size(), 1u) << "Benchmark mode: at least one "
196+
<< "options expected";
196197
return options[0];
197198
}();
198199
Check(tc, kernelName, bestOptions, inputs, check_fun);

0 commit comments

Comments
 (0)