fusion fix

This commit is contained in:
Abhishek Gola
2026-07-06 13:36:53 +05:30
parent 2089d7fdb1
commit 0843a0bb17
3 changed files with 67 additions and 0 deletions

View File

@@ -154,6 +154,9 @@ void Net::Impl::clear()
prepared = false;
finalizeLayers = true;
finalized = false;
fusedSnapshotValid = false;
fusedSnapshot.clear();
}
@@ -1419,6 +1422,9 @@ void Net::Impl::getLayerShapes(const ShapesVec& netInputShapes,
LayerShapes& shapes)
{
if (mainGraph) {
// Fusion emits block-layout layers; their TransformLayout conversions are
// only inserted by finalize(), so shape inference must run post-finalize.
finalize();
std::vector<MatShape> shapeCache;
std::vector<int> typeCache;
CV_Assert(layerId == 0);
@@ -2551,6 +2557,7 @@ int64 Net::Impl::getFLOPS(const std::vector<MatShape>& netInputShapes,
const std::vector<MatType>& netInputTypes) /*const*/
{
if (mainGraph) {
finalize();
// The new graph engine executes in FP32 on CPU regardless of the requested
// target, so FP16 input types (e.g. coming from an OpenCL FP16 target) would be
// rejected by Layer::getTypes(). Normalize them to FP32 for shape/FLOPS inference.
@@ -2584,6 +2591,7 @@ int64 Net::Impl::getFLOPS(
const std::vector<MatType>& netInputTypes) /*const*/
{
if (mainGraph) {
finalize();
std::vector<MatType> inputTypes = filterFP16InputTypes(netInputTypes);
LayerShapes shapes;
std::vector<MatShape> shapeCache;