From b654f58ae621ad8a38a59b7d6dc40020d27c6ebd Mon Sep 17 00:00:00 2001 From: Aaron Enye Shi Date: Wed, 16 Feb 2022 11:44:43 -0800 Subject: [PATCH] Fix namespace errors in PyTorch CI (#532) Summary: Pull Request resolved: https://github.com/pytorch/kineto/pull/532 PyTorch CI has some issues with the two namespaces such as Config defined in KINETO_NAMESPACE. Add using namespace to the failed areas. Test Plan: Fixes the errors on CI tests vulkan-bionic-py3.7-clang9, xenial-cuda11.3-py3.7-gcc7, xenial-py3.7-clang7-asan,xenial-py3.7-clang7-onnx, xenial-py3.7-gcc5.4, xenial-py3.7-gcc7, xenial-py3.6-gcc7-no-ops: ``` 2022-02-15T17:42:01.5120839Z In file included from /var/lib/jenkins/workspace/torch/csrc/autograd/profiler_kineto.cpp:23: 2022-02-15T17:42:01.5122878Z In file included from /var/lib/jenkins/workspace/third_party/kineto/libkineto/include/libkineto.h:18: 2022-02-15T17:42:01.5123681Z In file included from /var/lib/jenkins/workspace/third_party/kineto/libkineto/include/ActivityProfilerInterface.h:12: 2022-02-15T17:42:01.5125190Z /var/lib/jenkins/workspace/third_party/kineto/libkineto/include/IActivityProfiler.h:92:13: error: unknown type name 'Config'; did you mean 'KINETO_NAMESPACE::Config'? 2022-02-15T17:42:01.5127932Z const Config& config) = 0; 2022-02-15T17:42:01.5128356Z ^~~~~~ 2022-02-15T17:42:01.5128871Z KINETO_NAMESPACE::Config 2022-02-15T17:42:01.5129844Z /var/lib/jenkins/workspace/third_party/kineto/libkineto/include/Config.h:19:7: note: 'KINETO_NAMESPACE::Config' declared here 2022-02-15T17:42:01.5130467Z class Config : public AbstractConfig { 2022-02-15T17:42:01.5132737Z ^ 2022-02-15T17:42:01.5133430Z In file included from /var/lib/jenkins/workspace/torch/csrc/autograd/profiler_kineto.cpp:23: 2022-02-15T17:42:01.5134143Z In file included from /var/lib/jenkins/workspace/third_party/kineto/libkineto/include/libkineto.h:18: 2022-02-15T17:42:01.5134920Z In file included from /var/lib/jenkins/workspace/third_party/kineto/libkineto/include/ActivityProfilerInterface.h:12: 2022-02-15T17:42:01.5136267Z /var/lib/jenkins/workspace/third_party/kineto/libkineto/include/IActivityProfiler.h:99:13: error: unknown type name 'Config'; did you mean 'KINETO_NAMESPACE::Config'? 2022-02-15T17:42:01.5162842Z const Config& config) = 0; 2022-02-15T17:42:01.5163525Z ^~~~~~ 2022-02-15T17:42:01.5165565Z KINETO_NAMESPACE::Config 2022-02-15T17:42:01.5166108Z /var/lib/jenkins/workspace/third_party/kineto/libkineto/include/Config.h:19:7: note: 'KINETO_NAMESPACE::Config' declared here 2022-02-15T17:42:01.5166657Z class Config : public AbstractConfig { 2022-02-15T17:42:01.5166901Z ^ 2022-02-15T17:42:01.5167612Z ``` Reviewed By: briancoutinho Differential Revision: D34249427 Pulled By: aaronenyeshi fbshipit-source-id: 77bc184715579cc16d615c652ffebf54232e972b --- libkineto/include/IActivityProfiler.h | 2 ++ libkineto/include/ILoggerObserver.h | 4 ++-- libkineto/src/ILoggerObserver.cpp | 4 ++-- libkineto/src/LoggerCollector.h | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libkineto/include/IActivityProfiler.h b/libkineto/include/IActivityProfiler.h index e5af595be..f5d4b3fb8 100644 --- a/libkineto/include/IActivityProfiler.h +++ b/libkineto/include/IActivityProfiler.h @@ -17,6 +17,8 @@ namespace libkineto { +using namespace KINETO_NAMESPACE; + #ifdef _MSC_VER // workaround for the predefined ERROR macro on Windows #undef ERROR diff --git a/libkineto/include/ILoggerObserver.h b/libkineto/include/ILoggerObserver.h index d7a3e435e..4fce7851b 100644 --- a/libkineto/include/ILoggerObserver.h +++ b/libkineto/include/ILoggerObserver.h @@ -14,7 +14,7 @@ constexpr char kPostProcessingStage[] = "Post Processing"; #include #include -namespace KINETO_NAMESPACE { +namespace libkineto { enum LoggerOutputType { VERBOSE = 0, @@ -45,6 +45,6 @@ class ILoggerObserver { }; -} // namespace KINETO_NAMESPACE +} // namespace libkineto #endif // !USE_GOOGLE_LOG diff --git a/libkineto/src/ILoggerObserver.cpp b/libkineto/src/ILoggerObserver.cpp index eaf711590..f01065788 100644 --- a/libkineto/src/ILoggerObserver.cpp +++ b/libkineto/src/ILoggerObserver.cpp @@ -9,7 +9,7 @@ #include #include -namespace KINETO_NAMESPACE { +namespace libkineto { struct LoggerTypeName { constexpr LoggerTypeName(const char* n, LoggerOutputType t) : name(n), type(t) {}; @@ -48,7 +48,7 @@ LoggerOutputType toLoggerOutputType(const std::string& str) { throw std::invalid_argument(fmt::format("Invalid activity type: {}", str)); } -} // namespace KINETO_NAMESPACE +} // namespace libkineto #endif // !USE_GOOGLE_LOG diff --git a/libkineto/src/LoggerCollector.h b/libkineto/src/LoggerCollector.h index 81b887438..bb05aab21 100644 --- a/libkineto/src/LoggerCollector.h +++ b/libkineto/src/LoggerCollector.h @@ -15,6 +15,8 @@ namespace KINETO_NAMESPACE { +using namespace libkineto; + class LoggerCollector : public ILoggerObserver { public: LoggerCollector() : buckets_() {}