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