FLImaging 7.8.25.3
ComputationalGraphSSIM.h
1#pragma once
2
3#if _MSC_VER >= 1900 && defined(_M_X64)
4
5#include "ComputationalGraph.h"
6#include "DefinitionsAI.h"
7#include "BackendConv2D.h"
8#include "BackendSSIM.h"
9
10namespace FLImaging
11{
12 namespace AI
13 {
14
15 template <typename T>
16 class FL_EXPORT CComputationalGraphSSIM : public CComputationalGraph<T>
17 {
18 protected:
19 CComputationalGraphSSIM();
20 CComputationalGraphSSIM(const CComputationalGraphSSIM<T>& cg);
21
22 public:
23 CComputationalGraphSSIM(const CComputationalBase<T>& cbOperand1, const CComputationalBase<T>& cbOperand2, int64_t i64FilterSize = 11, T tFilterSigma = (T)1.5, T tMaxDiffValue = (T)INFINITY, T tK1 = (T)0.01, T tK2 = (T)0.03, bool bReturnIndexMap = false);
24 virtual ~CComputationalGraphSSIM();
25
26 virtual CTensor<T>& Forward() override;
27 virtual CTensor<T>* Backward() override;
28 virtual CComputationalBase<T>* Clone() const override;
29
30 virtual const std::vector<int64_t>& GetEstimatedShape(bool bRecursive = true) const override;
31 virtual const CResult PrintNodeParamInfo() const override;
32
33 virtual const CResult GetBinaryData(Base::CFLData& fldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
34 virtual const CResult GetBinaryData(Base::CFLData* pFldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
35 virtual const CResult SetBinaryData(const Base::CFLData& fldBinary, int64_t* pI64Offset = nullptr) override;
36 virtual const CResult SetBinaryData(const Base::CFLData* pFldBinary, int64_t* pI64Offset = nullptr) override;
37
38 virtual int64_t GetRequiredTemporaryMemory(bool bTraining = false, bool bRecursively = true, int64_t i64BatchSize = 1, int64_t i64MemoryIndex = 0) const override;
39 virtual int64_t GetRequiredDedicatedMemory(bool bTraining = false, bool bRecursively = true, int64_t i64BatchSize = 1) const override;
40
41 DeclareGetClassType();
42 SupportToDuplicateObjectWithoutCreateNewObject(CComputationalGraphSSIM, *this);
43
44 protected:
45 T m_tMaxDiffValue;
46 T m_tFilterSigma;
47 T m_tK1;
48 T m_tK2;
49
50 int64_t m_i64FilterSize;
51 bool m_bReturnIndexMap;
52
53 CBackendConv2D<T> m_backendConv2D;
54 CBackendSSIM<T> m_backendSSIM;
55
56 public:
57 DeclareGetSignletonObject(CComputationalGraphSSIM);
58 };
59
60 #define CCGFSSIM(...) (*(new CComputationalGraphSSIM<float>(__VA_ARGS__)))
61 #define CCGDSSIM(...) (*(new CComputationalGraphSSIM<double>(__VA_ARGS__)))
62
63 #define CCGTSSIM(T, ...) (*(new CComputationalGraphSSIM<T>(__VA_ARGS__)))
64 }
65}
66
67#endif
Definition AlgorithmAIBase.h:18