FLImaging 6.5.16.1
ComputationalGraphSmoothL1Loss.h
1#pragma once
2
3#if _MSC_VER >= 1900 && defined(_M_X64)
4
5#include "ComputationalGraph.h"
6#include "BackendSmoothL1Loss.h"
7#include "DefinitionsAI.h"
8
9namespace FLImaging
10{
11 namespace AI
12 {
13 template <typename T>
14 class FL_EXPORT CComputationalGraphSmoothL1Loss : public CComputationalGraph<T>
15 {
16
17 private:
18 CComputationalGraphSmoothL1Loss();
19
20 protected:
21 CComputationalGraphSmoothL1Loss(const CComputationalGraphSmoothL1Loss<T>& cg);
22
23 public:
24 CComputationalGraphSmoothL1Loss(const CComputationalBase<T>& cbOperand1, const CComputationalBase<T>& tsrAnswer, EReductionType eReductionType = EReductionType_Mean, const T tBeta = 1.);
25 virtual ~CComputationalGraphSmoothL1Loss();
26
27 virtual CTensor<T>& Forward() override;
28 virtual CTensor<T>* Backward() override;
29 virtual CComputationalBase<T>* Clone() const override;
30
31 virtual const std::vector<int64_t>& GetEstimatedShape(bool bRecursive = true) const override;
32 virtual const CResult PrintNodeParamInfo() const override;
33
34 virtual const CResult GetBinaryData(Base::CFLData& fldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
35 virtual const CResult GetBinaryData(Base::CFLData* pFldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
36
37 virtual const CResult SetBinaryData(const Base::CFLData& fldBinary, int64_t* pI64Offset = nullptr) override;
38 virtual const CResult SetBinaryData(const Base::CFLData* pFldBinary, int64_t* pI64Offset = nullptr) override;
39
40 virtual int64_t GetRequiredDedicatedMemory(bool bTraining = false, bool bRecursively = true, int64_t i64BatchSize = 1) const override;
41
42 DeclareGetClassType();
43 SupportToDuplicateObjectWithoutCreateNewObject(CComputationalGraphSmoothL1Loss, *this);
44 private:
45 EReductionType m_eReductionType;
46 T m_tBeta;
47
48 CBackendSmoothL1Loss<T> m_backendSmoothL1Loss;
49 public:
50 DeclareGetSignletonObject(CComputationalGraphSmoothL1Loss);
51 };
52
53 #define CCGFSmoothL1Loss(...) (*(new CComputationalGraphSmoothL1Loss<float>(__VA_ARGS__)))
54 #define CCGDSmoothL1Loss(...) (*(new CComputationalGraphSmoothL1Loss<double>(__VA_ARGS__)))
55
56 #define CCGTSmoothL1Loss(T, ...) (*(new CComputationalGraphSmoothL1Loss<T>(__VA_ARGS__)))
57 }
58}
59
60#endif