Skip to content

Commit

Permalink
fix github action
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoqing committed Jan 10, 2025
1 parent f401404 commit 7d2313b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 25 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions assets/images/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/TensorflowCpy/include/tensorflow_cpy/tensorflow.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {
Expand Down
51 changes: 31 additions & 20 deletions src/TensorflowCpy/source/framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ 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 <tensorflow_cpy/tensorflow.h>

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 <tensorflow/cc/saved_model/loader.h>
# include <tensorflow/cc/saved_model/tag_constants.h>
# include <tensorflow/core/common_runtime/device/device_id.h>
Expand All @@ -54,13 +54,19 @@ namespace se = tensorflow_cpy::stream_executor;
# include <tensorflow/core/platform/types.h>
# include <tensorflow/core/public/session.h>
# include <tensorflow/core/util/stream_executor_util.h>
# 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;

Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down Expand Up @@ -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<uint8_t>(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_A.IsInitialized()<<std::endl;
std::vector<uint8_t> input_tensor_B_host(shape.num_elements());
Expand Down Expand Up @@ -311,3 +321,4 @@ int tensorflow_cpy::main_whole_flow(int argc, char** argv) {

return 0;
}
#pragma GCC diagnostic pop
1 change: 1 addition & 0 deletions src/TensorflowCpy/source/tensorflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7d2313b

Please sign in to comment.