Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15363
Didn't define C10_MOBILE in the numa file move diff:
D13380559
move CAFFE2_MOBILE/ANDROID/IOS to c10
```
codemod -m -d caffe2 --extensions h,hpp,cc,cpp,mm "CAFFE2_MOBILE" "C10_MOBILE"
codemod -m -d caffe2 --extensions h,hpp,cc,cpp,mm "CAFFE2_ANDROID" "C10_ANDROID"
codemod -m -d caffe2 --extensions h,hpp,cc,cpp,mm "CAFFE2_IOS" "C10_IOS"
```
i-am-not-moving-c2-to-c10
Reviewed By: marcinkwiatkowski
Differential Revision:
D13490020
fbshipit-source-id:
c4f01cacbefc0f16d5de94155c26c92fd5d780e4
// Macros used during the build of this caffe2 instance. This header file
// is automatically generated by the cmake script during build.
-#include "caffe2/core/common.h"
#include "caffe2/core/macros.h"
-#include "c10/macros/Macros.h"
+#include <c10/macros/Macros.h>
#include "c10/util/string_utils.h"
#define CAFFE2_USED __attribute__((__used__))
#endif //_MSC_VER
-// Define enabled when building for iOS or Android devices
-#if !defined(CAFFE2_MOBILE)
-#if defined(__ANDROID__)
-#define CAFFE2_ANDROID 1
-#define CAFFE2_MOBILE 1
-#elif (defined(__APPLE__) && \
- (TARGET_IPHONE_SIMULATOR || TARGET_OS_SIMULATOR || TARGET_OS_IPHONE))
-#define CAFFE2_IOS 1
-#define CAFFE2_MOBILE 1
-#elif (defined(__APPLE__) && TARGET_OS_MAC)
-#define CAFFE2_IOS 1
-#define CAFFE2_MOBILE 0
-#else
-#define CAFFE2_MOBILE 0
-#endif // ANDROID / IOS / MACOS
-#endif // CAFFE2_MOBILE
-
// Define alignment macro that is cross platform
#if defined(_MSC_VER)
#define CAFFE2_ALIGNED(x) __declspec(align(x))
(CAFFE2_VERSION_MAJOR * 10000 + CAFFE2_VERSION_MINOR * 100 + \
CAFFE2_VERSION_PATCH)
-#cmakedefine CAFFE2_ANDROID
#cmakedefine CAFFE2_BUILD_SHARED_LIBS
#cmakedefine CAFFE2_FORCE_FALLBACK_CUDA_MPI
#cmakedefine CAFFE2_HAS_MKL_DNN
#include "caffe2/core/flags.h"
#include "caffe2/core/tensor.h"
-#if defined(CAFFE2_USE_MPSCNN) && CAFFE2_MOBILE
+#if defined(CAFFE2_USE_MPSCNN) && C10_MOBILE
#include "caffe2/mobile/contrib/ios/mpscnn/mpscnn.h"
#endif
bool allowMetalOperators) {
caffe2::NetDef metal_predict_net;
bool usingMetalOperators = false;
-#if defined(CAFFE2_USE_MPSCNN) && CAFFE2_MOBILE
+#if defined(CAFFE2_USE_MPSCNN) && C10_MOBILE
if (allowMetalOperators) {
caffe2::dumpDef(predict_net);
if (caffe2::tryConvertToMPSCNN(init_net, predict_net, &metal_predict_net)) {
bool disableMultithreadProcessing,
bool usingMetalOperators)
: usingMetalOperators(usingMetalOperators), predictor_(init_net, predict_net) {
-#if CAFFE2_MOBILE
+#if C10_MOBILE
if (disableMultithreadProcessing) {
caffe2::ThreadPool* threadpool = predictor_.ws()->GetThreadPool();
if (threadpool != nullptr) {
#include "caffe2/core/common.h"
#include "caffe2/core/context.h"
-#if defined(CAFFE2_USE_MPSCNN) && CAFFE2_MOBILE
+#if defined(CAFFE2_USE_MPSCNN) && C10_MOBILE
#include "caffe2/core/operator.h"
#include "caffe2/core/timer.h"
#include "caffe2/core/common.h"
-#if CAFFE2_MOBILE
+#if C10_MOBILE
#include "mpscnn_context.h"
#include "mpscnn_kernels.h"
#include "caffe2/core/common.h"
-#if CAFFE2_MOBILE && defined(CAFFE2_USE_MPSCNN_TEST)
+#if C10_MOBILE && defined(CAFFE2_USE_MPSCNN_TEST)
#include "mpscnn_context.h"
#include "mpscnn_graph_mask.h"
// r->WQL1Norm.mutable_data<float>()[i] *= center_distance;
// }
state->parallelFor = [ws](size_t range, std::function<void(size_t)> f) {
-#if CAFFE2_MOBILE
+#if C10_MOBILE
ws->GetThreadPool()->run([&](int, size_t v) { f(v); }, range);
#else
for (size_t v = 0; v < range; ++v) {
}
std::string RunCountNetObserver::debugInfo() {
-#if CAFFE2_ANDROID
+#if C10_ANDROID
// workaround
int foo = cnt_;
return "This operator runs " + c10::to_string(foo) + " times.";
#include "caffe2/utils/map_utils.h"
#include "caffe2/utils/proto_utils.h"
-#if !CAFFE2_MOBILE
+#if !C10_MOBILE
#include "onnx/checker.h"
#include "onnx/optimizer/optimize.h"
#endif
return d;
}
-#if !CAFFE2_MOBILE
+#if !C10_MOBILE
ModelProto OptimizeOnnx(const ModelProto& input, bool init) {
std::vector<std::string> passes{"fuse_consecutive_transposes",
"eliminate_nop_transpose",
const std::vector<Caffe2Ops>& extras) {
auto device_option = GetDeviceOption(Device(device));
-#if !CAFFE2_MOBILE
+#if !C10_MOBILE
ModelProto init_model = OptimizeOnnx(onnx_model, true);
ModelProto pred_model = OptimizeOnnx(onnx_model, false);
#else
ModelProto onnx_model;
ParseProtoFromLargeString(onnx_model_str, &onnx_model);
-#if !CAFFE2_MOBILE
+#if !C10_MOBILE
::ONNX_NAMESPACE::checker::check_model(onnx_model);
#endif
namespace caffe2 {
-#ifndef CAFFE2_MOBILE
+#ifndef C10_MOBILE
#error "mobile build state not defined"
#endif
-#if CAFFE2_MOBILE
+#if C10_MOBILE
// mobile-only implementation (tiled + vectorized + multithreaded)
REGISTER_CPU_OPERATOR_WITH_ENGINE(
ConvTranspose,
#include "caffe2/core/common.h"
-#ifndef CAFFE2_MOBILE
+#ifndef C10_MOBILE
#error "mobile build state not defined"
#endif
-#if CAFFE2_MOBILE
+#if C10_MOBILE
#include "caffe2/core/context.h"
#include "caffe2/core/operator.h"
} // namespace caffe2
-#endif // CAFFE2_MOBILE
+#endif // C10_MOBILE
#endif // CAFFE2_OPERATORS_CONV_TRANSPOSE_MOBILE_OP_H_
#include "caffe2/core/common.h"
-#ifndef CAFFE2_MOBILE
+#ifndef C10_MOBILE
#error "mobile build state not defined"
#endif
-#if CAFFE2_MOBILE
+#if C10_MOBILE
#include "caffe2/core/logging.h"
#include "caffe2/operators/conv_op_shared.h"
} // namespace caffe2
-#endif // CAFFE2_MOBILE
+#endif // C10_MOBILE
#endif // CAFFE2_OPERATORS_CONV_TRANSPOSE_MOBILE_OP_IMPL_H_
if (run_init) {
CAFFE_ENFORCE(ws.RunNetOnce(init_net));
}
-#if CAFFE2_MOBILE
+#if C10_MOBILE
GlobalInit();
#endif
if (optimization &&
Timer t;
-#if CAFFE2_MOBILE
+#if C10_MOBILE
ws_->GetThreadPool()->run(
[&](int, int n_g) {
const int g = n_g / N;
#include "caffe2/core/init.h"
#include "caffe2/core/workspace.h"
-#if CAFFE2_ANDROID
+#if C10_ANDROID
#ifndef SYS_gettid
#define SYS_gettid __NR_gettid
#endif
int numThreads = cpuinfo_get_processors_count();
bool applyCap = false;
-#if CAFFE2_ANDROID
+#if C10_ANDROID
applyCap = FLAGS_caffe2_threadpool_android_cap;
-#elif CAFFE2_IOS
+#elif C10_IOS
applyCap = FLAGS_caffe2_threadpool_ios_cap;
#endif
if (applyCap) {
switch (numThreads) {
-#if CAFFE2_ANDROID && (CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64)
+#if C10_ANDROID && (CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64)
case 4:
switch (cpuinfo_get_core(0)->midr & UINT32_C(0xFF00FFF0)) {
case UINT32_C(0x51002110): /* Snapdragon 820 Kryo Silver */
// caffe2 depends upon NNPACK, which depends upon this threadpool, so
// unfortunately we can't reference core/common.h here
-// This is copied from core/common.h's definition of CAFFE2_MOBILE
+// This is copied from core/common.h's definition of C10_MOBILE
// Define enabled when building for iOS or Android devices
#if defined(__ANDROID__)
-#define CAFFE2_ANDROID 1
+#define C10_ANDROID 1
#elif (defined(__APPLE__) && \
(TARGET_IPHONE_SIMULATOR || TARGET_OS_SIMULATOR || TARGET_OS_IPHONE))
-#define CAFFE2_IOS 1
+#define C10_IOS 1
#elif (defined(__APPLE__) && TARGET_OS_MAC)
-#define CAFFE2_IOS 1
+#define C10_IOS 1
#else
#endif // ANDROID / IOS / MACOS
#include "observers/perf_observer.h"
#include "observers/observer_config.h"
-#if !CAFFE2_MOBILE
+#if !C10_MOBILE
#include "caffe2/core/flags.h"
#include "observers/net_observer_reporter_print.h"
#endif
#include "caffe2/core/init.h"
#include "caffe2/core/operator.h"
-#if !CAFFE2_MOBILE
+#if !C10_MOBILE
C10_DEFINE_int64(
aiBench_netInitSampleRate,
0,
return caffe2::make_unique<PerfNetObserver>(subject);
});
-#if !CAFFE2_MOBILE
+#if !C10_MOBILE
// for aibench usage
caffe2::ObserverConfig::setReporter(
caffe2::make_unique<caffe2::NetObserverReporterPrint>());