FLImaging 6.12.9.2
ComputationalGraphBCEWithLogistLoss.h
1#pragma once
2
3#if _MSC_VER >= 1900 && defined(_M_X64)
4
5#include "ComputationalGraphBinaryCrossEntropyLoss.h"
6#include "BackendBCEWithLogistLoss.h"
7#include "DefinitionsAI.h"
8
9namespace FLImaging
10{
11 namespace AI
12 {
13
14 template <typename T>
15 class FL_EXPORT CComputationalGraphBCEWithLogistLoss : public CComputationalGraphBinaryCrossEntropyLoss<T>
16 {
17 protected:
18 CComputationalGraphBCEWithLogistLoss();
19 CComputationalGraphBCEWithLogistLoss(const CComputationalGraphBCEWithLogistLoss<T>& cg);
20
21 public:
22 CComputationalGraphBCEWithLogistLoss(const CComputationalBase<T>& cbOperand1, const CComputationalBase<T>& tsrAnswer, const CTensor<T>* pTsrWeights = nullptr, EReductionType eReductionType = EReductionType_Mean, const CTensor<T>* pTsrPosWeight = nullptr);
23 virtual ~CComputationalGraphBCEWithLogistLoss();
24
25 virtual CTensor<T>& Forward() override;
26 virtual CTensor<T>* Backward() override;
27 virtual CComputationalBase<T>* Clone() const override;
28
29 virtual const CResult GetBinaryData(Base::CFLData& fldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
30 virtual const CResult GetBinaryData(Base::CFLData* pFldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
31
32 virtual const CResult SetBinaryData(const Base::CFLData& fldBinary, int64_t* pI64Offset = nullptr) override;
33 virtual const CResult SetBinaryData(const Base::CFLData* pFldBinary, int64_t* pI64Offset = nullptr) override;
34
35 virtual int64_t GetRequiredDedicatedMemory(bool bTraining = false, bool bRecursively = true, int64_t i64BatchSize = 1) const override;
36
37 DeclareGetClassType();
38 SupportToDuplicateObjectWithoutCreateNewObject(CComputationalGraphBCEWithLogistLoss, *this);
39
40 protected:
41 virtual const CResult BroadCasting(const CTensor<T>& tsrSrc, const std::vector<int64_t>& vctResultShape, CTensor<T>& tsrResult);
42
43 CBackendBCEWithLogistLoss<T> m_backendBCEWithLogistLoss;
44 CTensor<T> m_tsrWeightsBroadcastBuffer;
45 CTensor<T> m_tsrPosWeights;
46 CTensor<T> m_tsrPosWeightsBroadcastBuffer;
47 public:
48 DeclareGetSignletonObject(CComputationalGraphBCEWithLogistLoss);
49 };
50
51 #define CCGFBCEWithLogistLoss(...) (*(new CComputationalGraphBCEWithLogistLoss<float>(__VA_ARGS__)))
52 #define CCGDBCEWithLogistLoss(...) (*(new CComputationalGraphBCEWithLogistLoss<double>(__VA_ARGS__)))
53
54 #define CCGTBCEWithLogistLoss(T, ...) (*(new CComputationalGraphBCEWithLogistLoss<T>(__VA_ARGS__)))
55 }
56}
57
58#endif
Definition AlgorithmAIBase.h:18