26 #ifndef NVNEURAL_SCRIPTENGINEANYOP_H
27 #define NVNEURAL_SCRIPTENGINEANYOP_H
39 AnyOperand(
const AnyOperand& val);
40 AnyOperand(
void* pVal);
41 AnyOperand(
const Float16& val);
44 AnyOperand(
const T& val)
46 if (std::is_floating_point<T>::value)
50 else if (std::is_integral<T>::value)
54 else if (!std::is_pointer<T>::value)
66 AnyOperand& operator=(
const AnyOperand& val);
69 void setInteger(T val)
71 m_depth =
sizeof(T) * 8;
73 m_signed = std::is_signed<T>::value;
80 m_depth =
sizeof(T) * 8;
89 if (std::is_floating_point<T>::value || std::is_same<T, Float16>::value)
91 if (m_type == INTEGER || m_type == REAL)
96 else if (std::is_integral<T>::value)
98 if (m_type == INTEGER || m_type == REAL)
103 else if (std::is_pointer<T>::value)
105 return m_type == POINTER;
113 if (std::is_floating_point<T>::value || std::is_same<T, Float16>::value)
115 if (m_type == INTEGER)
120 const double rTemp =
static_cast<double>(m_evaluation.s);
121 m_evaluation.r = rTemp;
125 const double rTemp =
static_cast<double>(m_evaluation.u);
126 m_evaluation.r = rTemp;
129 m_depth =
sizeof(T) * 8;
132 else if (m_type == REAL)
134 m_depth =
sizeof(T) * 8;
138 else if (std::is_integral<T>::value)
140 if (m_type == INTEGER)
142 m_depth =
sizeof(T) * 8;
143 m_signed = std::is_signed<T>::value;
146 else if (m_type == REAL)
149 const int64_t sTemp =
static_cast<int64_t
>(m_evaluation.r);
150 m_evaluation.s = sTemp;
151 m_signed = std::is_signed<T>::value;
152 m_depth =
sizeof(T) * 8;
161 void setPointer(
void* pVal,
int memsize = 0);
171 static std::vector<AnyOperand> divUp(
const AnyOperand& op1,
const AnyOperand& op2,
bool typing);
172 static std::vector<AnyOperand> findDivisor(
const AnyOperand& x,
bool typing);
174 void sub(
const AnyOperand& op,
bool fp16,
bool typing);
175 void add(
const AnyOperand& op,
bool fp16,
bool typing);
177 void mul(
const AnyOperand& op,
bool typing);
178 void div(
const AnyOperand& op,
bool typing);
180 void neg(
bool typing);
182 TypeCode type()
const;
185 int sizeInBytes()
const;
186 void* representation();
200 rv = double(m_evaluation.s);
204 rv = double(m_evaluation.u);
217 T rv = T(m_evaluation.s);
220 rv = T(m_evaluation.r);
225 void* pointer()
const;
229 uint64_t masked_unsigned()
const;
231 void typeUpdate(
const AnyOperand& op,
bool blockToPointer);
234 bool m_signed =
false;
235 TypeCode m_type = WRONG;
244 } m_evaluation = {0}, m_representation = {0};
Fundamental NvNeural data types are declared here.