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 m_evaluation.r = m_evaluation.s;
124 m_evaluation.r = m_evaluation.u;
127 m_depth =
sizeof(T) * 8;
130 else if (m_type == REAL)
132 m_depth =
sizeof(T) * 8;
136 else if (std::is_integral<T>::value)
138 if (m_type == INTEGER)
140 m_depth =
sizeof(T) * 8;
141 m_signed = std::is_signed<T>::value;
144 else if (m_type == REAL)
147 m_evaluation.s = m_evaluation.r;
148 m_signed = std::is_signed<T>::value;
149 m_depth =
sizeof(T) * 8;
158 void setPointer(
void* pVal,
int memsize = 0);
168 static std::vector<AnyOperand> divUp(
const AnyOperand& op1,
const AnyOperand& op2,
bool typing);
169 static std::vector<AnyOperand> findDivisor(
const AnyOperand& x,
bool typing);
171 void sub(
const AnyOperand& op,
bool fp16,
bool typing);
172 void add(
const AnyOperand& op,
bool fp16,
bool typing);
174 void mul(
const AnyOperand& op,
bool typing);
175 void div(
const AnyOperand& op,
bool typing);
177 void neg(
bool typing);
179 TypeCode type()
const;
182 int sizeInBytes()
const;
183 void* representation();
197 rv = double(m_evaluation.s);
201 rv = double(m_evaluation.u);
214 T rv = T(m_evaluation.s);
217 rv = T(m_evaluation.r);
222 void* pointer()
const;
226 uint64_t masked_unsigned()
const;
228 void typeUpdate(
const AnyOperand& op,
bool blockToPointer);
231 bool m_signed =
false;
232 TypeCode m_type = WRONG;
241 } m_evaluation, m_representation;
Fundamental NvNeural data types are declared here.