FLImaging 6.5.16.1
ComputationalGraphReshape.h
1#pragma once
2
3#if _MSC_VER >= 1900 && defined(_M_X64)
4
5#include "ComputationalGraph.h"
6
7#include <vector>
8
9namespace FLImaging
10{
11 namespace AI
12 {
13 template <typename T>
14 class FL_EXPORT CComputationalGraphReshape : public CComputationalGraph<T>
15 {
16 private:
17 CComputationalGraphReshape();
18
19 protected:
20 CComputationalGraphReshape(const CComputationalGraphReshape<T>& cg);
21
22 public:
23 CComputationalGraphReshape(const CComputationalBase<T>& cbOperand);
24 CComputationalGraphReshape(const CComputationalBase<T>& cbOperand, const CComputationalBase<T>& cbReferenceShape);
25 CComputationalGraphReshape(const CComputationalBase<T>& cbOperand, const std::vector<int64_t>& vctReshape);
26 CComputationalGraphReshape(const CComputationalBase<T>& cbOperand, const std::initializer_list<int64_t>& ilReshape);
27 virtual ~CComputationalGraphReshape();
28
29 virtual CTensor<T>& Forward() override;
30 virtual CTensor<T>* Backward() override;
31 virtual CComputationalBase<T>* Clone() const override;
32
33 virtual const CResult Swap(CComputationalBase<T>& cbSwap) override;
34 virtual const std::vector<int64_t>& GetEstimatedShape(bool bRecursive = true) const override;
35
36 virtual const CResult GetBinaryData(Base::CFLData& fldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
37 virtual const CResult GetBinaryData(Base::CFLData* pFldBinary, bool bSuperClass = false, int32_t i32Version = -1, bool bDumpMode = false) const override;
38
39 virtual const CResult SetBinaryData(const Base::CFLData& fldBinary, int64_t* pI64Offset = nullptr) override;
40 virtual const CResult SetBinaryData(const Base::CFLData* pFldBinary, int64_t* pI64Offset = nullptr) override;
41
42 virtual const CResult PrintNodeParamInfo() const override;
43
44 virtual const CResult SetReShape(const std::vector<int64_t> vctShape);
45 const std::vector<int64_t>& GetReShape() const;
46
47 DeclareGetClassType();
48 SupportToDuplicateObjectWithoutCreateNewObject(CComputationalGraphReshape, *this);
49
50 protected:
51 std::vector<int64_t>& m_vctReshape;
52 public:
53 DeclareGetSignletonObject(CComputationalGraphReshape);
54 };
55
56 #define CCGFReshape(...) (*(new CComputationalGraphReshape<float>(__VA_ARGS__)))
57 #define CCGDReshape(...) (*(new CComputationalGraphReshape<double>(__VA_ARGS__)))
58
59 #define CCGTReshape(T, ...) (*(new CComputationalGraphReshape<T>(__VA_ARGS__)))
60 }
61}
62
63#endif