OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] Add debug transformation to selectively force FP32 precision (#36006)
Paul Youngsoo Ahn5cd585f0a456
diff --git a/src/plugins/intel_gpu/docs/gpu_debug_utils.md b/src/plugins/intel_gpu/docs/gpu_debug_utils.mdindex 14579f5a16b..8a0c5a85093 100644--- a/src/plugins/intel_gpu/docs/gpu_debug_utils.md+++ b/src/plugins/intel_gpu/docs/gpu_debug_utils.md@@ -60,6 +60,8 @@ These are the most commonly used GPU debug knobs.| `OV_VERBOSE` | Verbosity level. Supported range: `0` (disabled) to `4` (maximum). || `OV_GPU_LOG_TO_FILE` | Saves verbose logs to the specified file. || `OV_GPU_LIST_LAYERS` | Set to `1` to print the list of executed primitives. This is a subset of the `OV_VERBOSE` log. |+| `OV_GPU_FORCE_FP32_LAYER_TYPES` | Space-separated operation types, including the optional `PASSTHROUGH_OPS` alias, to promote from FP16 to FP32. See [Selective FP32 precision](#selective-fp32-precision). |+| `OV_GPU_FORCE_FP32_LAYER_NAMES` | Space-separated friendly-name substrings to select for FP32 promotion. Combined with the type filter using AND. || `OV_DYNAMIC_QUANTIZATION_GROUP_SIZE` | Sets the dynamic quantization group size. For best accuracy, disable dynamic quantization by setting this value to `0`. || `OV_ACTIVATIONS_SCALE_FACTOR` | Scalar floating-point value used for runtime activation tensor scaling. This is mainly useful for accuracy troubleshooting where `NaN` or `inf` is created in the middle of network execution. || `OV_GPU_DUMP_GRAPHS_PATH` | Saves intermediate graph representations during model compilation to the specified directory. Useful for debugging fusion, layout selection, or opt-out decisions. See the graph dump section below for details. |@@ -94,6 +96,73 @@ Non default env value for VERBOSE = 1...```+## Selective FP32 precision++Use `ForceFP32Selective` to investigate FP16 accuracy issues by promoting selected operations' FP16 inputs and outputs to FP32. This feature requires `ENABLE_DEBUG_CAPS=ON` and `ENABLE_GPU_DEBUG_CAPS=ON`. Sources remain in the build lists, following the GPU debug helper pattern. When GPU debug caps are disabled, `GPU_DEBUG_CONFIG` guards exclude the pass declaration, implementation, registration, and unit tests during preprocessing. Configuration options use the standard `OV_CONFIG_DEBUG_OPTION` mechanism, controlled by `ENABLE_DEBUG_CAPS`.++The pass runs at the end of the GPU model transformation pipeline, after precision conversion and fusion. Filters use the operation's current type (`get_type_name()`) and friendly name at this stage. For example, an original `MatMul` may already be `FullyConnected`, and an RMS pattern may be fused into the internal `RMS` operation. Use types and names from the transformed model; names from the original model may have changed.++### Filters and examples++Both variables accept **space-separated** values. Quote a list in the shell; commas do not separate values. Operation type matching is exact and case-sensitive; `PASSTHROUGH_OPS` is a reserved type-list alias. Name matching uses case-sensitive substrings, with no regular expressions or wildcards.++| Type list | Name list | Initial selection |+|---|---|---|+| Empty | Empty | No changes. |+| Set | Empty | Any listed type (OR). |+| Empty | Set | Any listed name substring (OR). |+| Set | Set | A listed type AND a listed name substring. |++A matching operation must have at least one FP16 output. If no operation qualifies, the pass makes no changes. GPU `Placeholder`, model `Parameter`/`Result`, and operations with no outputs are excluded from initial selection.++The examples below set only the filters shown. Leave the other filter unset when using type-only or name-only selection. Replace the example names with friendly-name substrings present in your transformed model.++```bash+# Type-only: select FullyConnected OR RMS.+OV_GPU_FORCE_FP32_LAYER_TYPES="FullyConnected RMS" ./benchmark_app -m model.xml -d GPU++# Name-only: select names containing block.19 OR ff.net.0.proj.+OV_GPU_FORCE_FP32_LAYER_NAMES="block.19 ff.net.0.proj" ./benchmark_app -m model.xml -d GPU++# Combined: select RMS nodes whose names contain block.19; print changed ports.+OV_GPU_FORCE_FP32_LAYER_TYPES="RMS" OV_GPU_FORCE_FP32_LAYER_NAMES="block.19" \+OV_VERBOSE=2 ./benchmark_app -m model.xml -d GPU++# Opt in to FP32 data movement operations as well as RMS.+OV_GPU_FORCE_FP32_LAYER_TYPES="RMS PASSTHROUGH_OPS" ./benchmark_app -m model.xml -d GPU+```++### Selection region and precision boundaries++The region contains only operations selected by the filters; there is no automatic propagation to neighboring operations. To include intermediate data movement operations, list their types or names explicitly, or add `PASSTHROUGH_OPS` to the type list.++`PASSTHROUGH_OPS` matches `Reshape`, `Transpose`, `Squeeze`, `Unsqueeze`, `StridedSlice`, `Gather`, `Concat`, `Split`, `VariadicSplit`, `ShapeOf`, and `Broadcast`. This is a model-wide type alias, not a search for paths between target operations. Without a name filter, it also selects disconnected operations and branches of these types. With a name filter, alias matches must satisfy the same name condition. Only FP16 outputs qualify, so integer ShapeOf outputs are preserved.++For example, `OV_GPU_FORCE_FP32_LAYER_TYPES="RMS PASSTHROUGH_OPS"` selects RMS and the listed data movement types across the model. Adding `OV_GPU_FORCE_FP32_LAYER_NAMES="block.19"` restricts both groups to matching names; intermediate nodes with other names remain unselected.++Only originally FP16 output ports are promoted. Existing FP32, integer, boolean, and BF16 outputs keep their types; for example, TopK values are promoted while its integer indices remain unchanged. External FP16 inputs get FP32 Converts, and outputs leaving the region are restored to their original FP16 type. Model input and output types remain unchanged.++Unselected intermediate operations keep their FP16 boundaries. A path such as selected FP32 operation → FP16 Reshape/Transpose → selected FP32 operation still introduces FP16 rounding. Select all required intermediate operations to keep that path FP32; the alias makes this an explicit user choice.++Region nodes connect directly where possible. FP16/FP32 Convert chains can be bypassed on a selected input edge when they lead back to a promoted region output or an external FP32 source. Other consumers keep the original chain. Chains containing integer, boolean, or BF16 conversions, or starting from an external FP16 producer, are preserved.++### Supported scope and limits++The unit suite covers filtering (type-only, name-only, OR within lists, AND between lists, and no matches), internal RMS and GPU FullyConnected precision attributes, TypeRelaxed overrides, mixed output types, internal and shared Convert edges, explicit pass-through selection and alias/name filtering, and Placeholder inputs. Selected arithmetic graphs are also evaluated to check rounding and preservation of unselected branches. The pass updates recognized FP16 output precision attributes as well as output descriptors; these tests do not establish GPU kernel execution precision.++Constant data, shared state (`ReadValue`/`Assign` and caches), and `Loop`/`If` boundaries are not fully supported. The pass does not recursively select operations inside subgraph bodies. Constant, state, and subgraph operations are excluded from precision attribute updates, but are not all excluded by the initial filters; avoid selecting them until coordinated type handling is implemented. Separate calculation attributes such as `RMSNorm::compute_type` are not updated.++Widening an already rounded FP16 value to FP32 does not recover the lost precision. This applies to previously compressed constants and values produced outside the region. Check the compiled runtime graph and GPU results to confirm the execution precision and accuracy of the selected operations.++With `OV_VERBOSE=2` or higher, the pass logs changed graph output ports. Example output (without the file/line prefix):++```text+[ForceFP32Selective] FORCED: type=RMS name=block.19.rms output=0 f16->f32+[ForceFP32Selective] Done. Region=1 Forced=1 Outputs=1+```++`Region` is the number of operations selected by the filters, `Forced` counts nodes with logged promotions still present in the model, and `Outputs` counts their promoted ports. Unmatched or unchanged nodes have no `FORCED` entry. Logs describe the graph at the end of this pass, before automatic validation and GPU kernel selection; they do not confirm kernel execution precision.+## Dump execution graphThe execution graph (also known as a runtime graph) is a device-specific graph after all transformations applied by the plugin. It is a very usefuldiff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/internal_properties.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/internal_properties.hppindex aa098dc60d5..a64b77a09b4 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/internal_properties.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/internal_properties.hpp@@ -241,6 +241,8 @@ static constexpr Property<std::vector<int>, ov::PropertyMutability::RW> micro_sdstatic constexpr Property<int, ov::PropertyMutability::RW> micro_sdpa_disable_prefetch{"GPU_MICRO_SDPA_DISABLE_PREFETCH"};static constexpr Property<std::string, ov::PropertyMutability::RW> pa_mixed_route_mode{"GPU_PA_MIXED_ROUTE_MODE"};static constexpr Property<bool, PropertyMutability::RW> record_replay_dynamic{"GPU_RECORD_REPLAY_DYNAMIC"};+static constexpr Property<std::vector<std::string>, ov::PropertyMutability::RW> force_fp32_layer_types{"GPU_FORCE_FP32_LAYER_TYPES"};+static constexpr Property<std::vector<std::string>, ov::PropertyMutability::RW> force_fp32_layer_names{"GPU_FORCE_FP32_LAYER_NAMES"};} // namespace ov::intel_gpunamespace cldnn {diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl b/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inlindex c9f306dcc5a..a731165b8e7 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl@@ -141,3 +141,5 @@ OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, pa_integrity_check, false, "Enable in-kernOV_CONFIG_DEBUG_OPTION(ov::intel_gpu, micro_sdpa_workgroup_config, std::vector<int>{}, "Override SDPA micro-kernel workgroup config: 4 ints [wg_m_kq wg_n_kq wg_m_vs wg_n_vs]")OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, micro_sdpa_disable_prefetch, 0, "Disable SDPA micro-kernel prefetches (Xe-HPC+). Bitmask: 1 - attn mask, 2 - K, 4 - V, 7 - all")OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, record_replay_dynamic, false, "Enable level-zero command list through record and replay for all (static and dynamic) models. Feature is work in progress and may produce incorrect results.")+OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, force_fp32_layer_types, std::vector<std::string>{}, "Space separated list of layer types to force FP32 precision; PASSTHROUGH_OPS selects data movement types (no automatic propagation)")+OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, force_fp32_layer_names, std::vector<std::string>{}, "Space separated list of layer name substrings to force FP32 precision (AND with layer_types if both set)")diff --git a/src/plugins/intel_gpu/sources.cmake b/src/plugins/intel_gpu/sources.cmakeindex ce2f76795f0..4558b489337 100644--- a/src/plugins/intel_gpu/sources.cmake+++ b/src/plugins/intel_gpu/sources.cmake@@ -172,6 +172,7 @@ set(GPU_PLUGIN_TRANSFORMATIONS_SOURCES${CMAKE_CURRENT_LIST_DIR}/src/plugin/transformations/fc_per_layer_scaling.cpp${CMAKE_CURRENT_LIST_DIR}/src/plugin/transformations/fold_activation_transpose.cpp${CMAKE_CURRENT_LIST_DIR}/src/plugin/transformations/fold_rms_transposes.cpp+ ${CMAKE_CURRENT_LIST_DIR}/src/plugin/transformations/force_fp32_selective.cpp${CMAKE_CURRENT_LIST_DIR}/src/plugin/transformations/fuse_atan2_decomposed.cpp${CMAKE_CURRENT_LIST_DIR}/src/plugin/transformations/fuse_avg_down.cpp${CMAKE_CURRENT_LIST_DIR}/src/plugin/transformations/fuse_grouped_depth_to_space.cppdiff --git a/src/plugins/intel_gpu/src/plugin/transformations/force_fp32_selective.cpp b/src/plugins/intel_gpu/src/plugin/transformations/force_fp32_selective.cppnew file mode 100644index 00000000000..910cb28da15--- /dev/null+++ b/src/plugins/intel_gpu/src/plugin/transformations/force_fp32_selective.cpp@@ -0,0 +1,357 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "force_fp32_selective.hpp"++#ifdef GPU_DEBUG_CONFIG++#include <algorithm>+#include <memory>+#include <string>+#include <unordered_map>+#include <unordered_set>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/convert.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"+#include "openvino/op/util/multi_subgraph_base.hpp"+#include "openvino/op/util/variable_extension.hpp"+#include "openvino/pass/manager.hpp"+#include "intel_gpu/op/placeholder.hpp"+#include "intel_gpu/runtime/debug_configuration.hpp"+#include "plugin/transformations/utils.hpp"++namespace ov {+namespace intel_gpu {++namespace {++// Update explicit precision attributes as well as the inferred output descriptor.+// Otherwise validation can restore an operation's original f16 output type.+class FP32AttributeVisitor : public ov::AttributeVisitor {+public:+ void on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) override {+ if (name == "output_type" || name == "destination_type" || name == "out_type") {+ if (auto* type = ov::as_type<ov::AttributeAdapter<ov::element::Type>>(&adapter)) {+ if (type->get() == "f16")+ type->set("f32");+ } else if (auto* type = ov::as_type<ov::AttributeAdapter<ov::element::Type_t>>(&adapter)) {+ if (type->get() == "f16")+ type->set("f32");+ }+ } else if (name == "input_data_types" || name == "output_data_types") {+ if (auto* types = ov::as_type<ov::AttributeAdapter<ov::element::TypeVector>>(&adapter)) {+ auto value = types->get();+ std::replace(value.begin(), value.end(), ov::element::f16, ov::element::f32);+ types->set(value);+ }+ }+ }++ // Do not recurse into nested attributes or subgraphs.+ void on_adapter(const std::string&, ov::VisitorAdapter&) override {}+};++void promote_precision_attributes(const std::shared_ptr<ov::Node>& node) {+ // Constants, model boundaries, and shared state require coordinated conversion.+ if (ov::is_type<ov::op::v0::Constant>(node) || ov::is_type<ov::op::v0::Parameter>(node) ||+ ov::is_type<ov::op::v0::Result>(node) || ov::is_type<ov::op::util::MultiSubGraphOp>(node) ||+ dynamic_cast<ov::op::util::VariableExtension*>(node.get())) {+ return;+ }++ FP32AttributeVisitor visitor;+ node->visit_attributes(visitor);+}++// Types selected explicitly through the PASSTHROUGH_OPS filter alias.+bool is_passthrough_op(const std::string& type_name) {+ static const std::unordered_set<std::string> passthrough_types = {+ "Reshape", "Transpose", "Squeeze", "Unsqueeze",+ "StridedSlice", "Gather", "Concat", "Split", "VariadicSplit",+ "ShapeOf", "Broadcast"+ };+ return passthrough_types.count(type_name) > 0;+}++bool matches_type(const std::vector<std::string>& forced_types, const std::string& type_name) {+ for (const auto& type : forced_types) {+ if (type == type_name || (type == "PASSTHROUGH_OPS" && is_passthrough_op(type_name)))+ return true;+ }+ return false;+}++bool matches_name(const std::vector<std::string>& forced_names, const std::string& node_name) {+ for (const auto& pattern : forced_names) {+ if (node_name.find(pattern) != std::string::npos)+ return true;+ }+ return false;+}++bool has_fp16_output(const std::shared_ptr<ov::Node>& node) {+ for (const auto& output : node->outputs()) {+ if (output.get_element_type() == ov::element::f16)+ return true;+ }+ return false;+}++using OriginalOutputTypes = std::unordered_map<ov::Node*, ov::element::TypeVector>;++OriginalOutputTypes record_output_types(const std::shared_ptr<ov::Model>& model,+ const std::unordered_set<ov::Node*>& f32_region) {+ OriginalOutputTypes original_types;+ for (const auto& node : model->get_ops()) {+ if (f32_region.count(node.get()) == 0)+ continue;+ auto& types = original_types[node.get()];+ for (const auto& output : node->outputs())+ types.push_back(output.get_element_type());+ }+ return original_types;+}++bool is_fp32_region_output(const ov::Output<ov::Node>& output, const OriginalOutputTypes& original_types) {+ const auto it = original_types.find(output.get_node());+ if (it == original_types.end())+ return false;+ const auto type = it->second.at(output.get_index());+ return type == ov::element::f16 || type == ov::element::f32;+}++// Phase 1: Seed Collection — identify ops that match the user filter+std::unordered_set<ov::Node*> collect_seeds(+ const std::shared_ptr<ov::Model>& model,+ const std::vector<std::string>& forced_types,+ const std::vector<std::string>& forced_names) {+ const bool has_types = !forced_types.empty();+ const bool has_names = !forced_names.empty();+ std::unordered_set<ov::Node*> f32_region;++ for (const auto& node : model->get_ops()) {+ const std::string node_type = node->get_type_name();+ const std::string node_name = node->get_friendly_name();++ if (has_types && !matches_type(forced_types, node_type))+ continue;+ if (has_names && !matches_name(forced_names, node_name))+ continue;++ // GPU Placeholder represents an absent optional input, not a computation.+ if (ov::is_type<ov::intel_gpu::op::Placeholder>(node))+ continue;++ // Model boundaries keep their original types; outputless nodes are not seeds.+ if (ov::is_type<ov::op::v0::Parameter>(node) || ov::is_type<ov::op::v0::Result>(node) ||+ !has_fp16_output(node)) {+ continue;+ }++ f32_region.insert(node.get());+ }++ GPU_DEBUG_LOG << "[ForceFP32Selective] seeds: " << f32_region.size() << std::endl;+ return f32_region;+}++// Bypass FP16/FP32 Convert chains from promoted or already-FP32 producers.+ov::Output<ov::Node> find_fp32_source(ov::Output<ov::Node> source,+ const OriginalOutputTypes& original_types) {+ const auto original_source = source;+ while (original_types.count(source.get_node()) == 0) {+ const auto convert = ov::as_type_ptr<ov::op::v0::Convert>(source.get_node_shared_ptr());+ if (!convert)+ break;++ const auto source_type = convert->get_input_element_type(0);+ const auto destination_type = convert->get_destination_type();+ if ((source_type != ov::element::f16 && source_type != ov::element::f32) ||+ (destination_type != ov::element::f16 && destination_type != ov::element::f32)) {+ return original_source;+ }+ source = convert->input_value(0);+ }++ if (!is_fp32_region_output(source, original_types) && source.get_element_type() != ov::element::f32)+ return original_source;++ return source;+}++// Phase 2a: Input Promotion — insert f16->f32 boundary Converts at region+// entry points and force output type to f32.+std::pair<bool, size_t> promote_inputs(+ const std::shared_ptr<ov::Model>& model,+ const OriginalOutputTypes& original_types) {+ bool changed = false;+ size_t global_convert_idx = 0;+ const auto desired_et = ov::element::f32;++ const auto ordered_ops = model->get_ordered_ops();++ // Pass 1: Connect region nodes directly; convert only external f16 inputs.+ for (const auto& node : ordered_ops) {+ if (original_types.count(node.get()) == 0)+ continue;++ for (const auto& input : node->inputs()) {+ const auto incoming_output = input.get_source_output();+ const auto incoming_node = incoming_output.get_node_shared_ptr();+ // An absent optional input has no tensor to convert.+ if (ov::is_type<ov::intel_gpu::op::Placeholder>(incoming_node))+ continue;++ const auto input_et = incoming_output.get_element_type();+ if (input_et != ov::element::f16 && input_et != desired_et)+ continue;++ const auto fp32_source = find_fp32_source(incoming_output, original_types);+ if (is_fp32_region_output(fp32_source, original_types) ||+ fp32_source.get_element_type() == desired_et) {+ if (fp32_source != incoming_output)+ input.replace_source_output(fp32_source);+ continue;+ }++ // Change this edge only, preserving external Converts and their users.+ auto convert = std::make_shared<ov::op::v0::Convert>(incoming_output, desired_et);+ convert->set_friendly_name(+ incoming_node->get_friendly_name() + "_increase_precision_" ++ std::to_string(global_convert_idx));+ ov::copy_runtime_info(incoming_node, convert);+ input.replace_source_output(convert);+ global_convert_idx++;+ }+ }++ // Pass 2: Update explicit precision attributes and force FP16 outputs to f32.+ for (const auto& node : ordered_ops) {+ if (original_types.count(node.get()) == 0)+ continue;++ promote_precision_attributes(node);+ const auto& types = original_types.at(node.get());+ for (size_t port = 0; port < types.size(); port++) {+ if (types[port] == ov::element::f16)+ node->set_output_type(port, desired_et, node->get_output_partial_shape(port));+ }++ changed = true;+ }++ return {changed, global_convert_idx};+}++// Phase 2b: Output Restore — insert f32->f16 Converts at region exit points.+// Done separately after all promotions so that region-internal edges are never+// accidentally restored.+void restore_outputs(const std::shared_ptr<ov::Model>& model,+ const OriginalOutputTypes& original_types,+ size_t& global_convert_idx) {+ const auto desired_et = ov::element::f32;++ for (const auto& node : model->get_ops()) {+ if (original_types.count(node.get()) == 0)+ continue;++ const auto& types = original_types.at(node.get());+ for (const auto& output : node->outputs()) {+ const auto original_type = types.at(output.get_index());+ if (original_type != ov::element::f16 || output.get_element_type() != desired_et)+ continue;+ std::vector<ov::Input<ov::Node>> outside_consumers;+ for (const auto& target_input : output.get_target_inputs()) {+ if (original_types.count(target_input.get_node()) == 0) {+ outside_consumers.push_back(target_input);+ }+ }+ for (auto& target_input : outside_consumers) {+ auto* const existing_convert = ov::as_type<ov::op::v0::Convert>(target_input.get_node());+ if (existing_convert && existing_convert->get_destination_type() == original_type)+ continue;++ auto convert = std::make_shared<ov::op::v0::Convert>(output, original_type);+ convert->set_friendly_name(+ target_input.get_node()->shared_from_this()->get_friendly_name() ++ "_restore_precision_" + std::to_string(global_convert_idx));+ ov::copy_runtime_info(node, convert);+ if (ov::is_type<ov::op::v0::Result>(target_input.get_node()))+ convert->output(0).set_names(output.get_names());+ target_input.replace_source_output(convert);+ global_convert_idx++;+ }+ }+ }+}++// Report graph output transitions, excluding nodes disconnected by edge rewiring.+// This log does not describe the precision of the eventual GPU kernel.+void log_promoted_outputs(const std::shared_ptr<ov::Model>& model,+ const OriginalOutputTypes& original_types) {+ if (ExecutionConfig::get_verbose() < static_cast<int>(LogLevel::LOG))+ return;++ size_t forced_count = 0;+ size_t forced_output_count = 0;+ for (const auto& node : model->get_ordered_ops()) {+ const auto it = original_types.find(node.get());+ if (it == original_types.end())+ continue;++ bool node_promoted = false;+ for (const auto& output : node->outputs()) {+ const auto port = output.get_index();+ if (it->second.at(port) != ov::element::f16 || output.get_element_type() != ov::element::f32)+ continue;++ node_promoted = true;+ forced_output_count++;+ GPU_DEBUG_LOG << "[ForceFP32Selective] FORCED: type=" << node->get_type_name()+ << " name=" << node->get_friendly_name()+ << " output=" << port << " f16->f32" << std::endl;+ }+ if (node_promoted)+ forced_count++;+ }++ GPU_DEBUG_LOG << "[ForceFP32Selective] Done. Region=" << original_types.size()+ << " Forced=" << forced_count << " Outputs=" << forced_output_count << std::endl;+}++} // namespace++bool ForceFP32Selective::run_on_model(const std::shared_ptr<ov::Model>& model) {+ if (m_forced_types.empty() && m_forced_names.empty())+ return false;++ // Phase 1: Seed Collection+ auto f32_region = collect_seeds(model, m_forced_types, m_forced_names);+ if (f32_region.empty())+ return false;++ const auto original_types = record_output_types(model, f32_region);++ // Phase 2a: Input Promotion+ auto [changed, convert_idx] = promote_inputs(model, original_types);++ // Phase 2b: Output Restore+ restore_outputs(model, original_types, convert_idx);++ log_promoted_outputs(model, original_types);++ return changed;+}++} // namespace intel_gpu+} // namespace ov++#endif // GPU_DEBUG_CONFIGdiff --git a/src/plugins/intel_gpu/src/plugin/transformations/force_fp32_selective.hpp b/src/plugins/intel_gpu/src/plugin/transformations/force_fp32_selective.hppnew file mode 100644index 00000000000..390984f4dc8--- /dev/null+++ b/src/plugins/intel_gpu/src/plugin/transformations/force_fp32_selective.hpp@@ -0,0 +1,67 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include <memory>+#include <string>+#include <vector>++#include "openvino/pass/pass.hpp"++namespace ov {+namespace intel_gpu {++#ifdef GPU_DEBUG_CONFIG++/**+ * @brief Promote selected FP16 graph inputs and outputs to FP32 for accuracy debugging.+ *+ * Requires ENABLE_GPU_DEBUG_CAPS. Runs after GPU precision conversion and fusion;+ * filters use the current operation type and friendly name at this stage.+ *+ * Environment examples (leave the other filter unset for single-filter use):+ * OV_GPU_FORCE_FP32_LAYER_TYPES="FullyConnected RMS" ./benchmark_app -m model.xml -d GPU+ * OV_GPU_FORCE_FP32_LAYER_NAMES="block.19 ff.net.0.proj" ./benchmark_app -m model.xml -d GPU+ *+ * Values are space-separated. Types match exactly; names match substrings.+ * Matching is case-sensitive, with OR within each list and AND between lists.+ * Empty filters or no matching FP16 outputs produce no changes.+ * Parameter, Result, Placeholder, and outputless nodes are not initial targets.+ *+ * No automatic region expansion is performed. PASSTHROUGH_OPS is a type-list+ * alias for the documented data movement types across the model; the name+ * filter still applies. For example:+ * OV_GPU_FORCE_FP32_LAYER_TYPES="RMS PASSTHROUGH_OPS" ./benchmark_app -m model.xml -d GPU+ * Region-internal edges stay FP32; external FP16 inputs are converted and+ * region exits restore FP16. Unselected intermediate operations keep FP16+ * boundaries, which can introduce rounding between selected operations.+ * Only originally FP16 outputs are promoted; other output types are preserved.+ * Recognized FP16 precision attributes are updated on supported operations.+ *+ * Constant data, state, and subgraph boundaries are not fully supported;+ * subgraph bodies and separate calculation precision attributes are not updated.+ * Widening FP16 values cannot recover precision already lost. Changed-output+ * logs (OV_VERBOSE=2) do not establish the eventual GPU kernel precision.+ * See src/plugins/intel_gpu/docs/gpu_debug_utils.md for scope and examples.+ */+class ForceFP32Selective : public ov::pass::ModelPass {+public:+ OPENVINO_MODEL_PASS_RTTI("ForceFP32Selective");++ ForceFP32Selective(const std::vector<std::string>& forced_types,+ const std::vector<std::string>& forced_names)+ : m_forced_types(forced_types), m_forced_names(forced_names) {}++ bool run_on_model(const std::shared_ptr<ov::Model>& model) override;++private:+ std::vector<std::string> m_forced_types;+ std::vector<std::string> m_forced_names;+};++#endif // GPU_DEBUG_CONFIG++} // namespace intel_gpu+} // namespace ovdiff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cppindex 60836223d85..43fbaa794fa 100644--- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp@@ -143,6 +143,7 @@#include "plugin/transformations/disable_fp16_comp_cumsum_sin_gen.hpp"#include "plugin/transformations/disable_fp16_comp_sin_gen.hpp"#include "plugin/transformations/increase_rms_input_precision.hpp"+#include "plugin/transformations/force_fp32_selective.hpp"#include "transformations/common_optimizations/activations_scaling.hpp"#include "transformations/common_optimizations/broadcast_elementwise_fusion.hpp"#include "transformations/common_optimizations/broadcast_transition.hpp"@@ -1982,5 +1983,17 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {manager.register_pass<ov::pass::Validate>();manager.run_passes(func);}+#ifdef GPU_DEBUG_CONFIG+ {+ const auto& forced_types = config.get_force_fp32_layer_types();+ const auto& forced_names = config.get_force_fp32_layer_names();++ if (!forced_types.empty() || !forced_names.empty()) {+ ov::pass::Manager fp32_manager;+ fp32_manager.register_pass<ov::intel_gpu::ForceFP32Selective>(forced_types, forced_names);+ fp32_manager.run_passes(func);+ }+ }+#endif}} // namespace ov::intel_gpudiff --git a/src/plugins/intel_gpu/tests/unit/sources.cmake b/src/plugins/intel_gpu/tests/unit/sources.cmakeindex 0bc5136385f..a3c4aebda36 100644--- a/src/plugins/intel_gpu/tests/unit/sources.cmake+++ b/src/plugins/intel_gpu/tests/unit/sources.cmake@@ -332,6 +332,7 @@ set(GPU_UNIT_TESTS_SRCS${CMAKE_CURRENT_LIST_DIR}/transformations/fc_per_layer_scaling_test.cpp${CMAKE_CURRENT_LIST_DIR}/transformations/fold_activation_transpose_test.cpp${CMAKE_CURRENT_LIST_DIR}/transformations/fold_rms_transposes_test.cpp+ ${CMAKE_CURRENT_LIST_DIR}/transformations/force_fp32_selective_test.cpp${CMAKE_CURRENT_LIST_DIR}/transformations/fuse_avg_down_test.cpp${CMAKE_CURRENT_LIST_DIR}/transformations/fuse_atan2_decomposed_test.cpp${CMAKE_CURRENT_LIST_DIR}/transformations/fuse_grouped_depth_to_space_test.cpp@@ -421,6 +422,8 @@ set(GPU_UNIT_TESTS_TRANSFORMATIONS_SRCS${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fold_activation_transpose.hpp${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fold_rms_transposes.cpp${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fold_rms_transposes.hpp+ ${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/force_fp32_selective.cpp+ ${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/force_fp32_selective.hpp${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fuse_avg_down.cpp${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fuse_avg_down.hpp${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fuse_atan2_decomposed.cppdiff --git a/src/plugins/intel_gpu/tests/unit/transformations/force_fp32_selective_test.cpp b/src/plugins/intel_gpu/tests/unit/transformations/force_fp32_selective_test.cppnew file mode 100644index 00000000000..fd5831e4336--- /dev/null+++ b/src/plugins/intel_gpu/tests/unit/transformations/force_fp32_selective_test.cpp@@ -0,0 +1,409 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#ifdef GPU_DEBUG_CONFIG++#include <gtest/gtest.h>++#include <memory>+#include <string>+#include <tuple>+#include <vector>++#include "intel_gpu/op/fully_connected.hpp"+#include "intel_gpu/op/placeholder.hpp"+#include "openvino/core/any.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/type/float16.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/convert.hpp"+#include "openvino/op/multiply.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/relu.hpp"+#include "openvino/op/reshape.hpp"+#include "openvino/op/select.hpp"+#include "openvino/op/shape_of.hpp"+#include "openvino/op/split.hpp"+#include "openvino/op/subtract.hpp"+#include "openvino/op/transpose.hpp"+#include "openvino/pass/manager.hpp"+#include "openvino/runtime/tensor.hpp"+#include "ov_ops/rms.hpp"+#include "ov_ops/type_relaxed.hpp"+#include "plugin/transformations/force_fp32_selective.hpp"++namespace force_fp32_selective_test {++class MixedOutputOp : public ov::op::Op {+public:+ OPENVINO_OP("MixedOutputOp", "test");++ explicit MixedOutputOp(const ov::Output<ov::Node>& input) : Op({input}) {+ validate_and_infer_types();+ }++ void validate_and_infer_types() override {+ const auto shape = get_input_partial_shape(0);+ set_output_type(0, ov::element::i32, shape);+ set_output_type(1, get_input_element_type(0), shape);+ set_output_type(2, ov::element::f32, shape);+ set_output_type(3, ov::element::boolean, shape);+ set_output_type(4, ov::element::bf16, shape);+ }++ std::shared_ptr<ov::Node> clone_with_new_inputs(const ov::OutputVector& inputs) const override {+ return std::make_shared<MixedOutputOp>(inputs.at(0));+ }+};+++} // namespace force_fp32_selective_test++namespace {++using force_fp32_selective_test::MixedOutputOp;++void force_selected(const std::shared_ptr<ov::Model>& model) {+ ov::pass::Manager manager;+ manager.register_pass<ov::intel_gpu::ForceFP32Selective>(std::vector<std::string>{},+ std::vector<std::string>{"selected"});+ manager.run_passes(model);+ model->validate_nodes_and_infer_types();+}++size_t count_converts(const std::shared_ptr<ov::Model>& model) {+ size_t count = 0;+ for (const auto& node : model->get_ops()) {+ if (ov::is_type<ov::op::v0::Convert>(node))+ count++;+ }+ return count;+}++void check_filter_selection(const std::string& type_list,+ const std::string& name_list,+ unsigned int expected_mask) {+ SCOPED_TRACE(type_list + " / " + name_list);+ const auto types = type_list.empty() ? std::vector<std::string>{}+ : ov::Any(type_list).as<std::vector<std::string>>();+ const auto names = name_list.empty() ? std::vector<std::string>{}+ : ov::Any(name_list).as<std::vector<std::string>>();+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 4});+ auto alpha = std::make_shared<ov::op::v0::Relu>(input);+ auto beta = std::make_shared<ov::op::v0::Relu>(input);+ auto rms = std::make_shared<ov::op::internal::RMS>(input, 1e-5, ov::element::f16);+ alpha->set_friendly_name("block_alpha");+ beta->set_friendly_name("block_beta");+ rms->set_friendly_name("block_alpha_rms");+ const ov::NodeVector nodes{alpha, beta, rms};+ auto model = std::make_shared<ov::Model>(ov::OutputVector{alpha, beta, rms}, ov::ParameterVector{input});+ const auto original_ops = model->get_ordered_ops();+ ov::intel_gpu::ForceFP32Selective pass(types, names);++ EXPECT_EQ(pass.run_on_model(model), expected_mask != 0u);+ model->validate_nodes_and_infer_types();++ for (size_t port = 0; port < nodes.size(); port++) {+ EXPECT_EQ(nodes[port]->get_output_element_type(0),+ (expected_mask & (1u << port)) ? ov::element::f32 : ov::element::f16);+ EXPECT_EQ(model->get_output_element_type(port), ov::element::f16);+ if (!(expected_mask & (1u << port))) {+ EXPECT_EQ(nodes[port]->input_value(0), input->output(0));+ EXPECT_EQ(model->get_results()[port]->input_value(0), nodes[port]->output(0));+ }+ }+ EXPECT_EQ(input->get_element_type(), ov::element::f16);+ if (expected_mask == 0u) {+ EXPECT_EQ(count_converts(model), 0u);+ EXPECT_EQ(model->get_ordered_ops(), original_ops);+ }+}++TEST(ForceFP32Selective, FilterListsPreserveOrAndAndNoOpRules) {+ using FilterCase = std::tuple<std::string, std::string, unsigned int>;+ const std::vector<FilterCase> cases{+ {"", "", 0u},+ {"Relu RMS", "", 7u},+ {"", "alpha beta", 7u},+ {"Relu", "alpha", 1u},+ {"Relu", "missing", 0u},+ };+ for (const auto& [type_list, name_list, expected_mask] : cases)+ check_filter_selection(type_list, name_list, expected_mask);+}++TEST(ForceFP32Selective, TypeOnlyFilterMatchesAllNodesOfTheTypeAndUnknownTypeIsNoOp) {+ check_filter_selection("Relu", "", 3u);+ check_filter_selection("AbsentOp", "", 0u);+}++TEST(ForceFP32Selective, NameOnlyFilterMatchesSubstringsAndMissingNameIsNoOp) {+ check_filter_selection("", "alpha", 5u);+ check_filter_selection("", "missing", 0u);+}++TEST(ForceFP32Selective, CombinedListsIntersectAndDisjointMatchesAreNoOp) {+ check_filter_selection("Relu RMS", "beta missing", 2u);+ // Relu matches alpha/beta; the "rms" substring matches only RMS.+ check_filter_selection("Relu", "rms", 0u);+}++TEST(ForceFP32Selective, PrecisionAttributesSurviveAutomaticValidationCloneAndReapplication) {+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 4});+ auto condition = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, ov::Shape{1, 4});+ auto weights = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{2, 4}, {1});+ auto bias = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{2}, {0});+ auto rms = std::make_shared<ov::op::internal::RMS>(input, 1e-5, ov::element::f16);+ auto fc = std::make_shared<ov::intel_gpu::op::FullyConnected>(input, weights, bias, ov::element::f16);+ auto select = std::make_shared<ov::op::TypeRelaxed<ov::op::v1::Select>>(+ ov::op::v1::Select(condition, input, input),+ ov::element::TypeVector{ov::element::boolean, ov::element::f16, ov::element::dynamic},+ ov::element::TypeVector{ov::element::f16});+ rms->set_friendly_name("selected_rms");+ fc->set_friendly_name("selected_fc");+ select->set_friendly_name("selected_select");+ auto model = std::make_shared<ov::Model>(ov::OutputVector{rms, fc, select}, ov::ParameterVector{input, condition});+ ov::pass::Manager manager;+ manager.register_pass<ov::intel_gpu::ForceFP32Selective>(std::vector<std::string>{},+ std::vector<std::string>{"selected"});++ manager.run_passes(model);++ for (const auto& output : {rms->output(0), fc->output(0), select->output(0)})+ EXPECT_EQ(output.get_element_type(), ov::element::f32);+ EXPECT_EQ(fc->get_output_type(), ov::element::f32);+ EXPECT_EQ(select->get_origin_input_type(0), ov::element::boolean);+ EXPECT_EQ(select->get_origin_input_type(1), ov::element::f32);+ EXPECT_EQ(select->get_origin_input_type(2), ov::element::dynamic);+ EXPECT_EQ(select->get_overridden_output_type(0), ov::element::f32);+ EXPECT_EQ(rms->clone_with_new_inputs({input})->get_output_element_type(0), ov::element::f32);+ EXPECT_EQ(weights->get_element_type(), ov::element::f16);+ EXPECT_EQ(condition->get_element_type(), ov::element::boolean);+ const auto original_ops = model->get_ordered_ops();+ const auto convert_count = count_converts(model);+ ov::intel_gpu::ForceFP32Selective pass({}, {"selected"});+ EXPECT_FALSE(pass.run_on_model(model));+ EXPECT_EQ(model->get_ordered_ops(), original_ops);+ EXPECT_EQ(count_converts(model), convert_count);+}++TEST(ForceFP32Selective, MixedOutputsPromoteOnlyFP16Port) {+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});+ auto mixed = std::make_shared<MixedOutputOp>(input);+ auto consumer = std::make_shared<ov::op::v0::Relu>(mixed->output(1));+ mixed->set_friendly_name("selected_mixed");+ consumer->set_friendly_name("selected_consumer");+ input->set_friendly_name("selected_input");+ mixed->output(1).set_names({"mixed_tensor"});+ auto outputs = mixed->outputs();+ outputs.push_back(consumer);+ auto model = std::make_shared<ov::Model>(outputs, ov::ParameterVector{input});++ const auto original_names = model->output(1).get_names();+ model->get_results()[1]->set_friendly_name("selected_result");+ force_selected(model);++ EXPECT_EQ(model->output(1).get_names(), original_names);+ EXPECT_EQ(model->get_results()[1]->get_friendly_name(), "selected_result");+ EXPECT_EQ(input->get_element_type(), ov::element::f16);+ EXPECT_EQ(model->get_output_partial_shape(1), ov::PartialShape{1});+ const ov::element::TypeVector original_types{ov::element::i32,+ ov::element::f16,+ ov::element::f32,+ ov::element::boolean,+ ov::element::bf16};+ for (size_t port = 0; port < original_types.size(); port++) {+ EXPECT_EQ(mixed->get_output_element_type(port),+ port == 1 ? ov::element::f32 : original_types[port]);+ EXPECT_EQ(model->get_output_element_type(port), original_types[port]);+ if (port != 1) {+ EXPECT_EQ(model->get_results()[port]->input_value(0), mixed->output(port));+ }+ }+ EXPECT_EQ(consumer->input_value(0), mixed->output(1));+ EXPECT_EQ(consumer->get_output_element_type(0), ov::element::f32);+ EXPECT_EQ(count_converts(model), 3u);+}++TEST(ForceFP32Selective, InternalConnectionDoesNotRoundToFP16) {+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});+ auto factor = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{1}, {1.0009765625f});+ auto first = std::make_shared<ov::op::v1::Multiply>(input, factor);+ auto down = std::make_shared<ov::op::v0::Convert>(first, ov::element::f16);+ auto up = std::make_shared<ov::op::v0::Convert>(down, ov::element::f32);+ auto rounded = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{1}, {1.001953125f});+ auto half = std::make_shared<ov::op::v0::Convert>(up, ov::element::f16);+ auto second = std::make_shared<ov::op::v1::Subtract>(half, rounded);+ first->set_friendly_name("selected_first");+ second->set_friendly_name("selected_second");+ auto model = std::make_shared<ov::Model>(ov::OutputVector{second}, ov::ParameterVector{input});+ ov::Tensor data(ov::element::f16, ov::Shape{1});+ data.data<ov::float16>()[0] = ov::float16(1.0009765625f);+ ov::TensorVector before{ov::Tensor(ov::element::f16, ov::Shape{1})};+ ASSERT_TRUE(model->evaluate(before, {data}));+ EXPECT_EQ(static_cast<float>(before[0].data<ov::float16>()[0]), 0.0f);++ force_selected(model);++ EXPECT_EQ(second->input_value(0).get_node_shared_ptr(), first);+ ov::TensorVector after{ov::Tensor(ov::element::f16, ov::Shape{1})};+ ASSERT_TRUE(model->evaluate(after, {data}));+ EXPECT_EQ(static_cast<float>(after[0].data<ov::float16>()[0]), 0.00000095367431640625f);+}++TEST(ForceFP32Selective, ExternalSharedRoundTripKeepsUnselectedValues) {+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1});+ auto down = std::make_shared<ov::op::v0::Convert>(input, ov::element::f16);+ auto offset = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{1}, {1});+ auto selected = std::make_shared<ov::op::v1::Subtract>(down, offset);+ auto other = std::make_shared<ov::op::v0::Convert>(down, ov::element::f32);+ selected->set_friendly_name("selected");+ other->set_friendly_name("other");+ auto model = std::make_shared<ov::Model>(ov::OutputVector{selected, other}, ov::ParameterVector{input});+ ov::Tensor data(ov::element::f32, ov::Shape{1});+ data.data<float>()[0] = 1.0001f;+ ov::TensorVector expected{ov::Tensor(ov::element::f16, ov::Shape{1}),+ ov::Tensor(ov::element::f32, ov::Shape{1})};+ ASSERT_TRUE(model->evaluate(expected, {data}));++ force_selected(model);++ EXPECT_EQ(selected->input_value(0).get_node_shared_ptr(), input);+ EXPECT_EQ(other->input_value(0).get_node_shared_ptr(), down);+ EXPECT_EQ(down->input_value(0).get_node_shared_ptr(), input);+ ov::TensorVector actual{ov::Tensor(ov::element::f16, ov::Shape{1}),+ ov::Tensor(ov::element::f32, ov::Shape{1})};+ ASSERT_TRUE(model->evaluate(actual, {data}));+ EXPECT_EQ(static_cast<float>(expected[0].data<ov::float16>()[0]), 0.0f);+ EXPECT_EQ(static_cast<float>(actual[0].data<ov::float16>()[0]),+ static_cast<float>(ov::float16(data.data<float>()[0] - 1.0f)));+ EXPECT_GT(static_cast<float>(actual[0].data<ov::float16>()[0]), 0.0f);+ EXPECT_FLOAT_EQ(actual[1].data<float>()[0], expected[1].data<float>()[0]);+ EXPECT_NE(actual[1].data<float>()[0], data.data<float>()[0]);+}++TEST(ForceFP32Selective, PassThroughAliasIsExplicitAndRespectsNameFilter) {+ using AliasCase = std::tuple<std::string, std::string, bool, bool, bool>;+ // Flags: select target arithmetic, middle pass-through ops, other pass-through ops.+ const std::vector<AliasCase> cases{+ {"Multiply Subtract", "", true, false, false},+ {"", "target middle", true, true, false},+ {"Multiply Subtract PASSTHROUGH_OPS", "", true, true, true},+ {"Multiply Subtract PASSTHROUGH_OPS", "target middle", true, true, false},+ {"Multiply Subtract PASSTHROUGH_OPS", "target", true, false, false},+ {"PASSTHROUGH_OPS", "", false, true, true},+ };+ for (const auto& [type_list, name_list, targets_selected, middle_selected, others_selected] : cases) {+ SCOPED_TRACE(type_list + " / " + name_list);+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 4});+ auto factor = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{1}, {1.0009765625f});+ auto first = std::make_shared<ov::op::v1::Multiply>(input, factor);+ auto shape = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, {2, 2});+ auto reshape = std::make_shared<ov::op::v1::Reshape>(first, shape, false);+ auto order = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, {1, 0});+ auto transpose = std::make_shared<ov::op::v1::Transpose>(reshape, order);+ auto rounded = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{1}, {1.001953125f});+ auto second = std::make_shared<ov::op::v1::Subtract>(transpose, rounded);+ auto axis = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {1});+ auto split = std::make_shared<ov::op::v1::Split>(second, axis, 2);+ auto left = std::make_shared<ov::op::v0::Relu>(split->output(0));+ auto right = std::make_shared<ov::op::v0::Relu>(split->output(1));+ auto isolated = std::make_shared<ov::op::v1::Reshape>(input, shape, false);+ auto shape_of = std::make_shared<ov::op::v3::ShapeOf>(second, ov::element::i64);+ first->set_friendly_name("target_first");+ second->set_friendly_name("target_second");+ reshape->set_friendly_name("middle_reshape");+ transpose->set_friendly_name("middle_transpose");+ split->set_friendly_name("other_split");+ isolated->set_friendly_name("other_isolated");+ shape_of->set_friendly_name("middle_shape");+ auto model = std::make_shared<ov::Model>(ov::OutputVector{left, right, isolated, shape_of},+ ov::ParameterVector{input});+ const auto types = type_list.empty() ? std::vector<std::string>{}+ : ov::Any(type_list).as<std::vector<std::string>>();+ const auto names = name_list.empty() ? std::vector<std::string>{}+ : ov::Any(name_list).as<std::vector<std::string>>();+ ov::pass::Manager manager;+ manager.register_pass<ov::intel_gpu::ForceFP32Selective>(types, names);++ manager.run_passes(model);++ for (const auto& node : {first->output(0), second->output(0)})+ EXPECT_EQ(node.get_element_type(), targets_selected ? ov::element::f32 : ov::element::f16);+ EXPECT_EQ(reshape->get_output_element_type(0), middle_selected ? ov::element::f32 : ov::element::f16);+ EXPECT_EQ(transpose->get_output_element_type(0), middle_selected ? ov::element::f32 : ov::element::f16);+ for (const auto& output : split->outputs())+ EXPECT_EQ(output.get_element_type(), others_selected ? ov::element::f32 : ov::element::f16);+ EXPECT_EQ(isolated->get_output_element_type(0), others_selected ? ov::element::f32 : ov::element::f16);+ EXPECT_EQ(shape_of->get_output_element_type(0), ov::element::i64);+ EXPECT_EQ(reshape->input_value(1), shape->output(0));+ EXPECT_EQ(transpose->input_value(1), order->output(0));+ EXPECT_EQ(split->input_value(1), axis->output(0));+ EXPECT_EQ(left->get_output_element_type(0), ov::element::f16);+ EXPECT_EQ(right->get_output_element_type(0), ov::element::f16);+ for (size_t port = 0; port < 3; port++)+ EXPECT_EQ(model->get_output_element_type(port), ov::element::f16);+ EXPECT_EQ(model->get_output_element_type(3), ov::element::i64);+ if (targets_selected && middle_selected) {+ EXPECT_EQ(reshape->input_value(0), first->output(0));+ EXPECT_EQ(transpose->input_value(0), reshape->output(0));+ EXPECT_EQ(second->input_value(0), transpose->output(0));+ } else if (targets_selected) {+ auto down = ov::as_type_ptr<ov::op::v0::Convert>(reshape->input_value(0).get_node_shared_ptr());+ auto up = ov::as_type_ptr<ov::op::v0::Convert>(second->input_value(0).get_node_shared_ptr());+ ASSERT_NE(down, nullptr);+ ASSERT_NE(up, nullptr);+ EXPECT_EQ(down->get_destination_type(), ov::element::f16);+ EXPECT_EQ(down->input_value(0), first->output(0));+ EXPECT_EQ(up->get_destination_type(), ov::element::f32);+ EXPECT_EQ(up->input_value(0), transpose->output(0));+ }++ ov::Tensor data(ov::element::f16, ov::Shape{1, 4});+ for (size_t index = 0; index < data.get_size(); index++)+ data.data<ov::float16>()[index] = ov::float16(1.0009765625f);+ ov::TensorVector outputs{ov::Tensor(ov::element::f16, ov::Shape{2, 1}),+ ov::Tensor(ov::element::f16, ov::Shape{2, 1}),+ ov::Tensor(ov::element::f16, ov::Shape{2, 2}),+ ov::Tensor(ov::element::i64, ov::Shape{2})};+ ASSERT_TRUE(model->evaluate(outputs, {data}));+ const float expected = targets_selected && middle_selected ? 0.00000095367431640625f : 0.0f;+ for (size_t port = 0; port < 2; port++) {+ for (size_t index = 0; index < outputs[port].get_size(); index++)+ EXPECT_EQ(static_cast<float>(outputs[port].data<ov::float16>()[index]), expected);+ }+ }+}++TEST(ForceFP32Selective, RenamedPlaceholderRemainsAnAbsentOptionalInput) {+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 4});+ auto weights = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{2, 4}, {1});+ auto no_bias = std::make_shared<ov::intel_gpu::op::Placeholder>();+ auto producer = std::make_shared<ov::op::v0::Relu>(input);+ producer->set_friendly_name("input_Placeholder");+ auto selected = std::make_shared<ov::intel_gpu::op::FullyConnected>(producer,+ weights,+ no_bias,+ ov::element::f16);+ no_bias->set_friendly_name("selected_optional_input");+ selected->set_friendly_name("selected_Placeholder_fc");+ auto model = std::make_shared<ov::Model>(ov::OutputVector{selected}, ov::ParameterVector{input});++ force_selected(model);++ EXPECT_EQ(selected->input_value(2).get_node_shared_ptr(), no_bias);+ EXPECT_EQ(no_bias->get_output_element_type(0), ov::element::dynamic);+ EXPECT_EQ(no_bias->get_friendly_name(), "selected_optional_input");+ EXPECT_EQ(selected->get_input_element_type(2), ov::element::dynamic);+ EXPECT_EQ(selected->get_output_element_type(0), ov::element::f32);+ auto promote = ov::as_type_ptr<ov::op::v0::Convert>(selected->input_value(0).get_node_shared_ptr());+ ASSERT_NE(promote, nullptr);+ EXPECT_EQ(promote->input_value(0), producer->output(0));+ EXPECT_EQ(producer->get_output_element_type(0), ov::element::f16);+ EXPECT_EQ(count_converts(model), 3u);+}++} // namespace++#endif // GPU_DEBUG_CONFIG