FLImaging 6.5.16.1
ComputationalGraphLabel.h
1#pragma once
2
3#if _MSC_VER >= 1900 && defined(_M_X64)
4
5#include "ComputationalGraph.h"
6#include "BackendLabel.h"
7#include <vector>
8
9namespace FLImaging
10{
11 namespace AI
12 {
13 template <typename T>
14 class FL_EXPORT CComputationalGraphLabel : public CComputationalGraph<T>
15 {
16 protected:
17 CComputationalGraphLabel();
18 CComputationalGraphLabel(const CComputationalGraphLabel<T>& cg);
19
20 public:
21
22 CComputationalGraphLabel(const CComputationalBase<T>& cbOperand, ELabelMethod eLabelMethod, int64_t i64ClassCount);
23 virtual ~CComputationalGraphLabel();
24
25 virtual CTensor<T>& Forward() override;
26 virtual CTensor<T>* Backward() override;
27 virtual CComputationalBase<T>* Clone() const override;
28
29 virtual const std::vector<int64_t>& GetEstimatedShape(bool bRecursive = true) const override;
30 virtual const CResult PrintNodeParamInfo() const override;
31
32 virtual const CResult GetBinaryData(Base::CFLData& fldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
33 virtual const CResult GetBinaryData(Base::CFLData* pFldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
34
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 const CResult SetClassCount(int64_t i64ClassCount);
39 virtual int64_t GetClassCount() const;
40
41 virtual int64_t GetRequiredDedicatedMemory(bool bTraining = false, bool bRecursively = true, int64_t i64BatchSize = 1) const override;
42
43 DeclareGetClassType();
44 SupportToDuplicateObjectWithoutCreateNewObject(CComputationalGraphLabel, *this);
45 protected:
46
47 CBackendLabel<T> m_backendLabel;
48
49 ELabelMethod m_eLabelMethod;
50 int64_t m_i64ClassCount;
51 public:
52 DeclareGetSignletonObject(CComputationalGraphLabel);
53 };
54
55 #define CCGFLabel(...) (*(new CComputationalGraphLabel<float>(__VA_ARGS__)))
56 #define CCGDLabel(...) (*(new CComputationalGraphLabel<double>(__VA_ARGS__)))
57
58 #define CCGTLabel(T, ...) (*(new CComputationalGraphLabel<T>(__VA_ARGS__)))
59 }
60}
61
62#endif