Skip to content

Commit

Permalink
common: cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
WolframRhodium committed Apr 19, 2024
1 parent 4ed38c2 commit 4a4879e
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 42 deletions.
7 changes: 1 addition & 6 deletions common/convert_float_to_float16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <cmath>
#include <cstdint>
#include <cstring>
#include <limits>
#include <memory>
#include <optional>
#include <string>
Expand All @@ -19,11 +18,7 @@

#include <onnx/onnx_pb.h>


void convert_float_to_float16(
ONNX_NAMESPACE::ModelProto & model,
bool force_fp16_initializers
) noexcept;
#include "convert_float_to_float16.h"


namespace {
Expand Down
19 changes: 19 additions & 0 deletions common/convert_float_to_float16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef CONVERT_FLOAT_TO_FLOAT16_H
#define CONVERT_FLOAT_TO_FLOAT16_H

#include <string>
#include <unordered_set>

#include <onnx/onnx_pb.h>

void convert_float_to_float16(
ONNX_NAMESPACE::ModelProto & model,
bool force_fp16_initializers
// , bool keep_io_types = True
// , bool disable_shape_infer = True
// , const std::optional<std::unordered_set<std::string>> op_block_list = DEFAULT_OP_BLOCK_LIST
// , const std::optional<std::unordered_set<std::string>> op_block_list = {}
, const std::unordered_set<std::string> & op_block_list
) noexcept;

#endif
2 changes: 2 additions & 0 deletions common/onnx_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <onnx/onnx_pb.h>
#include <onnx/shape_inference/implementation.h>

#include "onnx_utils.h"


using namespace std::string_literals;

Expand Down
18 changes: 18 additions & 0 deletions common/onnx_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef ONNX_UTILS_H
#define ONNX_UTILS_H

#include <cstdint>
#include <string>
#include <string_view>
#include <variant>

#include <onnx/onnx_pb.h>

std::variant<std::string, ONNX_NAMESPACE::ModelProto> loadONNX(
const std::string_view & path,
int64_t tile_w,
int64_t tile_h,
bool path_is_serialization
) noexcept;

#endif
11 changes: 3 additions & 8 deletions vsncnn/vs_ncnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@
#include <net.h>
#include <gpu.h>

#include "config.h" // generated by cmake
#include <onnx/common/version.h>
#include "onnx2ncnn.hpp"

#include "../common/onnx_utils.h"
#include "onnx2ncnn.hpp"

extern std::variant<std::string, ONNX_NAMESPACE::ModelProto> loadONNX(
const std::string_view & path,
int64_t tile_w,
int64_t tile_h,
bool path_is_serialization
) noexcept;
#include "config.h" // generated by cmake


static const VSPlugin * myself = nullptr;
Expand Down
17 changes: 3 additions & 14 deletions vsort/vs_onnxruntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,10 @@ using namespace std::chrono_literals;
#include <dml_provider_factory.h>
#endif // ENABLE_DML

#include "config.h"

#include "../common/convert_float_to_float16.h"
#include "../common/onnx_utils.h"

extern std::variant<std::string, ONNX_NAMESPACE::ModelProto> loadONNX(
const std::string_view & path,
int64_t tile_w,
int64_t tile_h,
bool path_is_serialization
) noexcept;

extern void convert_float_to_float16(
ONNX_NAMESPACE::ModelProto & model,
bool force_fp16_initializers,
const std::unordered_set<std::string> & op_block_list
) noexcept;
#include "config.h"


#ifdef ENABLE_COREML
Expand Down
17 changes: 3 additions & 14 deletions vsov/vs_openvino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,10 @@
#include <openvino/pass/visualize_tree.hpp>
#endif // ENABLE_VISUALIZATION

#include "config.h"

#include "../common/convert_float_to_float16.h"
#include "../common/onnx_utils.h"

extern std::variant<std::string, ONNX_NAMESPACE::ModelProto> loadONNX(
const std::string_view & path,
int64_t tile_w,
int64_t tile_h,
bool path_is_serialization
) noexcept;

extern void convert_float_to_float16(
ONNX_NAMESPACE::ModelProto & model,
bool force_fp16_initializers,
const std::unordered_set<std::string> & op_block_list
) noexcept;
#include "config.h"


using namespace std::string_literals;
Expand Down

0 comments on commit 4a4879e

Please sign in to comment.