diff --git a/Libraries/DirectMLX.h b/Libraries/DirectMLX.h index e06018b..0d03b8e 100644 --- a/Libraries/DirectMLX.h +++ b/Libraries/DirectMLX.h @@ -3774,6 +3774,15 @@ namespace dml } #endif +#if DML_TARGET_VERSION >= 0x5000 + + inline Expression Negate(Expression input) + { + return detail::ElementWiseUnary(input); + } + +#endif // DML_TARGET_VERSION >= 0x5000 + // Reinterprets the memory of a tensor with a different type and dimensions (analogously to using // reinterpret_cast to access raw bits). Note that this is different to the DML Cast operator, which performs // a type cast on the contents of a tensor (analogously to static_cast). The total tensor size of the output @@ -3858,8 +3867,17 @@ namespace dml // Unary inline Expression operator~(Expression input) { return dml::BitNot(input); } inline Expression operator+(Expression input) { return dml::Identity(input); } + +#if DML_TARGET_VERSION >= 0x5000 + + inline Expression operator-(Expression input) { return dml::Negate(input); } + +#else + inline Expression operator-(Expression input) { return dml::Identity(input, DML_SCALE_BIAS{ -1.0f, 0.0f }); } +#endif // DML_TARGET_VERSION >= 0x5000 + // Logical inline Expression operator!(Expression a) { return dml::LogicalNot(a); } inline Expression operator&&(Expression a, Expression b) { return dml::LogicalAnd(a, b); }