forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4909305
commit 64ecc67
Showing
9 changed files
with
186 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
#include <set> | ||
#include <sstream> | ||
#include <string> | ||
#include <typeindex> | ||
#include <typeinfo> | ||
#include <unordered_map> | ||
#include <utility> | ||
|
||
#include "openvino/pass/pass.hpp" | ||
|
||
class HeightMap; | ||
|
||
|
||
namespace ov { | ||
namespace pass { | ||
/** | ||
* @brief UpcastToFP32ByName sets nodes to fp32 | ||
* @ingroup ov_pass_cpp_api | ||
*/ | ||
class OPENVINO_API UpcastToFP32ByName : public ModelPass { | ||
public: | ||
OPENVINO_RTTI("ov::pass::UpcastToFP32ByName"); | ||
|
||
explicit UpcastToFP32ByName(std::vector<std::string> node_names_list): nodes_to_keep_in_fp32(node_names_list) {} | ||
|
||
bool run_on_model(const std::shared_ptr<ov::Model>&) override; | ||
private: | ||
std::vector<std::string> nodes_to_keep_in_fp32; | ||
|
||
}; | ||
} // namespace pass | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "openvino/pass/upcast_to_fp32_by_name.hpp" | ||
#include "itt.hpp" | ||
|
||
#include <cmath> | ||
#include <fstream> | ||
#include "vector" | ||
#include "openvino/cc/pass/itt.hpp" | ||
#include "openvino/core/type.hpp" | ||
#include "openvino/op/constant.hpp" | ||
#include "openvino/op/parameter.hpp" | ||
#include "openvino/op/util/op_types.hpp" | ||
#include "openvino/util/common_util.hpp" | ||
|
||
#include "openvino/pass/manager.hpp" | ||
#include "openvino/pass/graph_rewrite.hpp" | ||
#include "transformations/rt_info/disable_fp16_compression.hpp" | ||
|
||
using namespace std; | ||
|
||
namespace ov { | ||
namespace pass { | ||
|
||
|
||
bool ov::pass::UpcastToFP32ByName::run_on_model(const std::shared_ptr<ov::Model> &f) { | ||
RUN_ON_MODEL_SCOPE(UpcastToFP32ByName); | ||
|
||
bool is_changed = false; | ||
for (auto &node: f->get_ops()) { | ||
if (std::count(nodes_to_keep_in_fp32.begin(), nodes_to_keep_in_fp32.end(), node->get_friendly_name())) { | ||
disable_fp16_compression(node); | ||
is_changed = true; | ||
} | ||
|
||
} | ||
|
||
return is_changed; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters