Skip to content

Commit 78d28ae

Browse files
author
Adrian Tsai
authored
Update DirectML samples to 1.5.0 redist (#106)
* Update samples to support DML 1.5.0 * Add ARM/ARM64 solution configurations * Add DML_TARGET_VERSION guards around new APIs in DirectMLX.h * Use different intermediate folders for HelloDirectML/HelloDirectMLX to allow parallel batch build without them stomping over one another
1 parent c545e71 commit 78d28ae

17 files changed

+1520
-99
lines changed

Libraries/DirectMLX.h

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,8 @@ namespace dml
10621062
return output;
10631063
}
10641064

1065+
#if DML_TARGET_VERSION >= 0x3100
1066+
10651067
inline Expression ClipGrad(Expression input, Expression inputGradient, float min, float max)
10661068
{
10671069
detail::GraphBuilder* builder = input.Impl()->GetGraphBuilder();
@@ -1084,6 +1086,8 @@ namespace dml
10841086
return output;
10851087
}
10861088

1089+
#endif // DML_TARGET_VERSION >= 0x3100
1090+
10871091
inline Expression Cos(Expression input, const Optional<DML_SCALE_BIAS>& scaleBias = NullOpt)
10881092
{
10891093
return detail::ElementWiseUnary<DML_OPERATOR_ELEMENT_WISE_COS, DML_ELEMENT_WISE_COS_OPERATOR_DESC>(input, scaleBias);
@@ -1254,11 +1258,15 @@ namespace dml
12541258
return detail::ElementWiseUnary<DML_OPERATOR_ELEMENT_WISE_SQRT, DML_ELEMENT_WISE_SQRT_OPERATOR_DESC>(input, scaleBias);
12551259
}
12561260

1261+
#if DML_TARGET_VERSION >= 0x3100
1262+
12571263
inline Expression DifferenceSquare(Expression a, Expression b)
12581264
{
12591265
return detail::ElementWiseBinary<DML_OPERATOR_ELEMENT_WISE_DIFFERENCE_SQUARE, DML_ELEMENT_WISE_DIFFERENCE_SQUARE_OPERATOR_DESC>(a, b);
12601266
}
12611267

1268+
#endif // DML_TARGET_VERSION >= 0x3100
1269+
12621270
inline Expression Subtract(Expression a, Expression b)
12631271
{
12641272
return detail::ElementWiseBinary<DML_OPERATOR_ELEMENT_WISE_SUBTRACT, DML_ELEMENT_WISE_SUBTRACT_OPERATOR_DESC>(a, b);
@@ -2659,6 +2667,8 @@ namespace dml
26592667
return output;
26602668
}
26612669

2670+
#if DML_TARGET_VERSION >= 0x3100
2671+
26622672
struct BatchNormalizationGradOutputs
26632673
{
26642674
Expression gradient;
@@ -2684,29 +2694,31 @@ namespace dml
26842694
TensorDesc outputScaleGradientTensor(meanTensor.dataType, meanTensor.sizes, builder->GetTensorPolicy());
26852695
TensorDesc outputBiasGradientTensor(meanTensor.dataType, meanTensor.sizes, builder->GetTensorPolicy());
26862696

2687-
DML_BATCH_NORMALIZATION_GRAD_OPERATOR_DESC bng_desc = {};
2688-
bng_desc.InputTensor = inputTensor.AsPtr<DML_TENSOR_DESC>();
2689-
bng_desc.InputGradientTensor = inputGradientTensor.AsPtr<DML_TENSOR_DESC>();
2690-
bng_desc.MeanTensor = meanTensor.AsPtr<DML_TENSOR_DESC>();
2691-
bng_desc.VarianceTensor = varianceTensor.AsPtr<DML_TENSOR_DESC>();
2692-
bng_desc.ScaleTensor = scaleTensor.AsPtr<DML_TENSOR_DESC>();
2693-
bng_desc.Epsilon = epsilon;
2697+
DML_BATCH_NORMALIZATION_GRAD_OPERATOR_DESC desc = {};
2698+
desc.InputTensor = inputTensor.AsPtr<DML_TENSOR_DESC>();
2699+
desc.InputGradientTensor = inputGradientTensor.AsPtr<DML_TENSOR_DESC>();
2700+
desc.MeanTensor = meanTensor.AsPtr<DML_TENSOR_DESC>();
2701+
desc.VarianceTensor = varianceTensor.AsPtr<DML_TENSOR_DESC>();
2702+
desc.ScaleTensor = scaleTensor.AsPtr<DML_TENSOR_DESC>();
2703+
desc.Epsilon = epsilon;
26942704

2695-
bng_desc.OutputGradientTensor = outputGradientTensor.AsPtr<DML_TENSOR_DESC>();
2696-
bng_desc.OutputScaleGradientTensor = outputScaleGradientTensor.AsPtr<DML_TENSOR_DESC>();
2697-
bng_desc.OutputBiasGradientTensor = outputBiasGradientTensor.AsPtr<DML_TENSOR_DESC>();
2705+
desc.OutputGradientTensor = outputGradientTensor.AsPtr<DML_TENSOR_DESC>();
2706+
desc.OutputScaleGradientTensor = outputScaleGradientTensor.AsPtr<DML_TENSOR_DESC>();
2707+
desc.OutputBiasGradientTensor = outputBiasGradientTensor.AsPtr<DML_TENSOR_DESC>();
26982708

26992709
dml::detail::NodeOutput* const inputs[] = { input.Impl(), inputGradient.Impl(), mean.Impl(), variance.Impl(), scale.Impl() };
2700-
dml::detail::NodeID node = builder->CreateOperatorNode(DML_OPERATOR_BATCH_NORMALIZATION_GRAD, &bng_desc, inputs);
2710+
dml::detail::NodeID node = builder->CreateOperatorNode(DML_OPERATOR_BATCH_NORMALIZATION_GRAD, &desc, inputs);
27012711

27022712
BatchNormalizationGradOutputs outputValues;
2703-
outputValues.gradient = builder->CreateNodeOutput(node, 0, *bng_desc.OutputGradientTensor);
2704-
outputValues.scaleGradient = builder->CreateNodeOutput(node, 1, *bng_desc.OutputScaleGradientTensor);
2705-
outputValues.biasGradient = builder->CreateNodeOutput(node, 2, *bng_desc.OutputBiasGradientTensor);
2713+
outputValues.gradient = builder->CreateNodeOutput(node, 0, *desc.OutputGradientTensor);
2714+
outputValues.scaleGradient = builder->CreateNodeOutput(node, 1, *desc.OutputScaleGradientTensor);
2715+
outputValues.biasGradient = builder->CreateNodeOutput(node, 2, *desc.OutputBiasGradientTensor);
27062716

27072717
return outputValues;
27082718
}
27092719

2720+
#endif // DML_TARGET_VERSION >= 0x3100
2721+
27102722
inline Expression MeanVarianceNormalization(
27112723
Expression input,
27122724
Optional<Expression> scale,

Samples/DirectMLSuperResolution/DirectMLSuperResolution.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,60 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectMLXSuperResolution",
1414
EndProject
1515
Global
1616
GlobalSection(SolutionConfigurationPlatforms) = preSolution
17+
Debug|ARM = Debug|ARM
18+
Debug|ARM64 = Debug|ARM64
1719
Debug|x64 = Debug|x64
1820
Debug|x86 = Debug|x86
21+
Release|ARM = Release|ARM
22+
Release|ARM64 = Release|ARM64
1923
Release|x64 = Release|x64
2024
Release|x86 = Release|x86
2125
EndGlobalSection
2226
GlobalSection(ProjectConfigurationPlatforms) = postSolution
27+
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Debug|ARM.ActiveCfg = Debug|ARM
28+
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Debug|ARM.Build.0 = Debug|ARM
29+
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Debug|ARM64.ActiveCfg = Debug|ARM64
30+
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Debug|ARM64.Build.0 = Debug|ARM64
2331
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Debug|x64.ActiveCfg = Debug|x64
2432
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Debug|x64.Build.0 = Debug|x64
2533
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Debug|x86.ActiveCfg = Debug|Win32
2634
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Debug|x86.Build.0 = Debug|Win32
35+
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Release|ARM.ActiveCfg = Release|ARM
36+
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Release|ARM.Build.0 = Release|ARM
37+
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Release|ARM64.ActiveCfg = Release|ARM64
38+
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Release|ARM64.Build.0 = Release|ARM64
2739
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Release|x64.ActiveCfg = Release|x64
2840
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Release|x64.Build.0 = Release|x64
2941
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Release|x86.ActiveCfg = Release|Win32
3042
{70CDBD87-F286-4EE0-87F1-5A1D09396CDA}.Release|x86.Build.0 = Release|Win32
43+
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Debug|ARM.ActiveCfg = Debug|ARM
44+
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Debug|ARM.Build.0 = Debug|ARM
45+
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Debug|ARM64.ActiveCfg = Debug|ARM64
46+
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Debug|ARM64.Build.0 = Debug|ARM64
3147
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Debug|x64.ActiveCfg = Debug|x64
3248
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Debug|x64.Build.0 = Debug|x64
3349
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Debug|x86.ActiveCfg = Debug|Win32
3450
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Debug|x86.Build.0 = Debug|Win32
51+
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Release|ARM.ActiveCfg = Release|ARM
52+
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Release|ARM.Build.0 = Release|ARM
53+
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Release|ARM64.ActiveCfg = Release|ARM64
54+
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Release|ARM64.Build.0 = Release|ARM64
3555
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Release|x64.ActiveCfg = Release|x64
3656
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Release|x64.Build.0 = Release|x64
3757
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Release|x86.ActiveCfg = Release|Win32
3858
{3E0E8608-CD9B-4C76-AF33-29CA38F2C9F0}.Release|x86.Build.0 = Release|Win32
59+
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Debug|ARM.ActiveCfg = Debug|ARM
60+
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Debug|ARM.Build.0 = Debug|ARM
61+
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Debug|ARM64.ActiveCfg = Debug|ARM64
62+
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Debug|ARM64.Build.0 = Debug|ARM64
3963
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Debug|x64.ActiveCfg = Debug|x64
4064
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Debug|x64.Build.0 = Debug|x64
4165
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Debug|x86.ActiveCfg = Debug|Win32
4266
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Debug|x86.Build.0 = Debug|Win32
67+
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Release|ARM.ActiveCfg = Release|ARM
68+
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Release|ARM.Build.0 = Release|ARM
69+
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Release|ARM64.ActiveCfg = Release|ARM64
70+
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Release|ARM64.Build.0 = Release|ARM64
4371
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Release|x64.ActiveCfg = Release|x64
4472
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Release|x64.Build.0 = Release|x64
4573
{31C25314-96AE-4EF0-84B7-0026C14F12AD}.Release|x86.ActiveCfg = Release|Win32

0 commit comments

Comments
 (0)