From 7d2313bc31cd3934556f1c47d16bd7804f416ce3 Mon Sep 17 00:00:00 2001 From: Nick Wang Date: Fri, 10 Jan 2025 11:04:28 +0800 Subject: [PATCH] fix github action --- .github/workflows/build.yml | 6 ++- Makefile | 2 +- assets/images/coverage.svg | 4 +- .../include/tensorflow_cpy/tensorflow.h | 16 ++++++ src/TensorflowCpy/source/framework.cpp | 51 +++++++++++-------- src/TensorflowCpy/source/tensorflow.cpp | 1 + 6 files changed, 55 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b32b71..fecb145 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,9 +20,11 @@ jobs: run: make poetry-download - name: Set up cache - uses: actions/cache@v4.0.2 + uses: actions/cache@v4 with: - path: .venv + path: | + .venv + third_party key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }} - name: Install dependencies run: | diff --git a/Makefile b/Makefile index 4eed645..72b2b0b 100644 --- a/Makefile +++ b/Makefile @@ -149,7 +149,7 @@ protobuf-install: #* Poetry .PHONY: poetry-download poetry-download: - curl -sSL https://install.python-poetry.org | python3 - + curl -sSL https://install.python-poetry.org | python3 - --version 1.8.4 ~/.local/share/pypoetry/venv/bin/pip install poetry-plugin-export .PHONY: poetry-remove diff --git a/assets/images/coverage.svg b/assets/images/coverage.svg index dba09e2..2d1c743 100644 --- a/assets/images/coverage.svg +++ b/assets/images/coverage.svg @@ -15,7 +15,7 @@ coverage coverage - 38% - 38% + 37% + 37% diff --git a/src/TensorflowCpy/include/tensorflow_cpy/tensorflow.h b/src/TensorflowCpy/include/tensorflow_cpy/tensorflow.h index 0f0551e..f3656b7 100644 --- a/src/TensorflowCpy/include/tensorflow_cpy/tensorflow.h +++ b/src/TensorflowCpy/include/tensorflow_cpy/tensorflow.h @@ -1,6 +1,21 @@ #ifndef TENSORFLOW_CPY_TENSORFLOW_H_ #define TENSORFLOW_CPY_TENSORFLOW_H_ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunknown-warning-option" + +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wpedantic" +#pragma GCC diagnostic ignored "-Wdeprecated-builtins" +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#pragma GCC diagnostic ignored "-Wignored-qualifiers" +#pragma GCC diagnostic ignored "-Winconsistent-missing-override" + +#pragma GCC diagnostic ignored "-Wswitch" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wunused-private-field" + #include "./tensorflow/cc/saved_model/loader.h" // IWYU pragma: keep #include "./tensorflow/cc/saved_model/tag_constants.h" // IWYU pragma: keep #include "./tensorflow/core/common_runtime/device/device_id.h" // IWYU pragma: keep @@ -28,6 +43,7 @@ #include "./tensorflow/stream_executor/device_memory.h" // IWYU pragma: keep #include "./tensorflow/stream_executor/platform.h" // IWYU pragma: keep #include "./tensorflow/stream_executor/stream_executor_pimpl.h" // IWYU pragma: keep +#pragma GCC diagnostic pop namespace tensorflow_cpy { namespace tensorflow { diff --git a/src/TensorflowCpy/source/framework.cpp b/src/TensorflowCpy/source/framework.cpp index 6167a45..fa81125 100644 --- a/src/TensorflowCpy/source/framework.cpp +++ b/src/TensorflowCpy/source/framework.cpp @@ -17,20 +17,6 @@ void wait_for_debugger_attach() { } } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunknown-warning-option" - -#pragma GCC diagnostic ignored "-Wunused-parameter" -#pragma GCC diagnostic ignored "-Wpedantic" -#pragma GCC diagnostic ignored "-Wdeprecated-builtins" -#pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#pragma GCC diagnostic ignored "-Wignored-qualifiers" -#pragma GCC diagnostic ignored "-Winconsistent-missing-override" - -#pragma GCC diagnostic ignored "-Wswitch" -#pragma GCC diagnostic ignored "-Wsign-compare" -#pragma GCC diagnostic ignored "-Wunused-variable" - #if ENABLE_TENSORFLOW_CPY # include @@ -38,6 +24,20 @@ void wait_for_debugger_attach() { namespace tf = tensorflow_cpy::tensorflow; namespace se = tensorflow_cpy::stream_executor; #else + +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunknown-warning-option" + +# pragma GCC diagnostic ignored "-Wunused-parameter" +# pragma GCC diagnostic ignored "-Wpedantic" +# pragma GCC diagnostic ignored "-Wdeprecated-builtins" +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +# pragma GCC diagnostic ignored "-Wignored-qualifiers" +# pragma GCC diagnostic ignored "-Winconsistent-missing-override" + +# pragma GCC diagnostic ignored "-Wswitch" +# pragma GCC diagnostic ignored "-Wsign-compare" +# pragma GCC diagnostic ignored "-Wunused-variable" # include # include # include @@ -54,13 +54,19 @@ namespace se = tensorflow_cpy::stream_executor; # include # include # include +# pragma GCC diagnostic pop namespace tf = tensorflow; namespace se = stream_executor; #endif -#pragma GCC diagnostic pop +#pragma GCC diagnostic push +// #pragma GCC diagnostic ignored "-Wunused-variable" +#define UNUSED(expr) \ + do { \ + (void)(expr); \ + } while (0) class TensorBufferView : public tf::TensorBuffer { std::size_t m_len; @@ -124,6 +130,9 @@ int tensorflow_cpy::main_whole_flow(int argc, char** argv) { // load ops tf::Env* env = tf::Env::Default(); + UNUSED(env); // TODO: handle this unused + tf::Status status; + assert(tf::OpRegistry::Global()->ProcessRegistrations().ok()); tf::OpRegistry::Global()->DeferRegistrations(); @@ -133,14 +142,15 @@ int tensorflow_cpy::main_whole_flow(int argc, char** argv) { for (const auto& op_so : fs::directory_iterator{ops_dir}) { if (op_so.is_directory()) continue; void* opHandle = nullptr; - assert(env->LoadDynamicLibrary(op_so.path().c_str(), &opHandle).ok()); + status = env->LoadDynamicLibrary(op_so.path().c_str(), &opHandle); + assert(status.ok()); } } assert(tf::OpRegistry::Global()->ProcessRegistrations().ok()); // load model tf::SavedModelBundle model; - auto status = tf::LoadSavedModel(sessionOption, runOption, model_path, {"serve"}, &model); + status = tf::LoadSavedModel(sessionOption, runOption, model_path, {"serve"}, &model); if (!status.ok()) { std::cerr << "Error happended when loading model: " << status.ToString() << std::endl; } @@ -269,9 +279,9 @@ int tensorflow_cpy::main_whole_flow(int argc, char** argv) { if (input_tensor_A.GetMemoryType() == tf::AllocatorMemoryType::kDevice) { auto ptr = tf::StreamExecutorUtil::AsDeviceMemory(input_tensor_A); // a[*] == 5; - assert(streamExecutor - ->SynchronousMemSet(&ptr, 5, input_tensor_A.NumElements() * sizeof(uint8_t)) - .ok()); + status = streamExecutor->SynchronousMemSet(&ptr, 5, + input_tensor_A.NumElements() * sizeof(uint8_t)); + assert(status.ok()); } // std::cerr< input_tensor_B_host(shape.num_elements()); @@ -311,3 +321,4 @@ int tensorflow_cpy::main_whole_flow(int argc, char** argv) { return 0; } +#pragma GCC diagnostic pop diff --git a/src/TensorflowCpy/source/tensorflow.cpp b/src/TensorflowCpy/source/tensorflow.cpp index b6264e2..eed015c 100644 --- a/src/TensorflowCpy/source/tensorflow.cpp +++ b/src/TensorflowCpy/source/tensorflow.cpp @@ -12,6 +12,7 @@ namespace tensorflow_cpy { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wunused-variable" namespace pcx = PyCXpress; namespace error = tensorflow::error; using Status = tensorflow::Status;