3#if _MSC_VER >= 1900 && defined(_M_X64)
5#include "ComputationalGraph.h"
6#include "BackendSoftmaxWithCrossEntropy.h"
7#include "DefinitionsAI.h"
15 class FL_EXPORT CComputationalGraphSoftmaxWithCrossEntropy :
public CComputationalGraph<T>
19 CComputationalGraphSoftmaxWithCrossEntropy();
22 CComputationalGraphSoftmaxWithCrossEntropy(
const CComputationalGraphSoftmaxWithCrossEntropy<T>& cg);
25 CComputationalGraphSoftmaxWithCrossEntropy(
const CComputationalBase<T>& cbOperand1,
const CComputationalBase<T>& tsrAnswer, CTensor<T>* pTsrWeights =
nullptr, EReductionType eReductionType = EReductionType_Mean, T tSmoothingVal = 0., int64_t i64IgnoreIndex = -1);
26 virtual ~CComputationalGraphSoftmaxWithCrossEntropy();
28 virtual CTensor<T>& Forward()
override;
29 virtual CTensor<T>* Backward()
override;
30 virtual CComputationalBase<T>* Clone()
const override;
32 virtual const std::vector<int64_t>& GetEstimatedShape(
bool bRecursive =
true)
const override;
33 virtual const CResult PrintNodeParamInfo()
const override;
35 virtual const CResult GetBinaryData(Base::CFLData& fldBinary,
bool bSuperClass =
false, int32_t i32Version = -1,
bool bDumpMode =
false)
const override;
36 virtual const CResult GetBinaryData(Base::CFLData* pFldBinary,
bool bSuperClass =
false, int32_t i32Version = -1,
bool bDumpMode =
false)
const override;
38 virtual const CResult SetBinaryData(
const Base::CFLData& fldBinary, int64_t* pI64Offset =
nullptr)
override;
39 virtual const CResult SetBinaryData(
const Base::CFLData* pFldBinary, int64_t* pI64Offset =
nullptr)
override;
41 virtual int64_t GetRequiredDedicatedMemory(
bool bTraining =
false,
bool bRecursively =
true, int64_t i64BatchSize = 1)
const override;
42 virtual int64_t GetRequiredTemporaryMemory(
bool bTraining =
false,
bool bRecursively =
true, int64_t i64BatchSize = 1, int64_t i64MemoryIndex = 0)
const override;
44 virtual int64_t GetIgnoreIndex()
const;
45 virtual const CResult SetIgnoreIndex(int64_t i64IgnoreIndex);
47 DeclareGetClassType();
48 SupportToDuplicateObjectWithoutCreateNewObject(CComputationalGraphSoftmaxWithCrossEntropy, *
this);
50 EReductionType m_eReductionType;
51 CTensor<T> m_tsrWeights;
52 CTensor<T> m_tsrSoftmax;
53 CTensor<T> m_tsrTargetBuffer;
57 int64_t m_i64IgnoreIndex;
59 CBackendSoftmaxWithCrossEntropy<T> m_backendCrossEntropy;
61 DeclareGetSignletonObject(CComputationalGraphSoftmaxWithCrossEntropy);
64 #define CCGFSoftmaxWithCrossEntropy(...) (*(new CComputationalGraphSoftmaxWithCrossEntropy<float>(__VA_ARGS__)))
65 #define CCGDSoftmaxWithCrossEntropy(...) (*(new CComputationalGraphSoftmaxWithCrossEntropy<double>(__VA_ARGS__)))
67 #define CCGTSoftmaxWithCrossEntropy(T, ...) (*(new CComputationalGraphSoftmaxWithCrossEntropy<T>(__VA_ARGS__)))