Skip to content

Commit c68ffb1

Browse files
author
Chris Elion
authored
change default barracuda behavior (#5175)
1 parent af6af94 commit c68ffb1

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

com.unity.ml-agents/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ interface was removed. (#5164)
3333
- Added ML-Agents package settings. (#5027)
3434
- Make com.unity.modules.unityanalytics an optional dependency. (#5109)
3535
- Make com.unity.modules.physics and com.unity.modules.physics2d optional dependencies. (#5112)
36+
- The default `InferenceDevice` is now `InferenceDevice.Default`, which is equivalent to `InferenceDevice.Burst`. If you
37+
depend on the previous behavior, you can explicitly set the Agent's `InferenceDevice` to `InferenceDevice.CPU`. (#5175)
38+
3639
#### ml-agents / ml-agents-envs / gym-unity (Python)
3740

3841
### Bug Fixes

com.unity.ml-agents/Runtime/Agent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ void NotifyAgentDone(DoneReason doneReason)
617617
public void SetModel(
618618
string behaviorName,
619619
NNModel model,
620-
InferenceDevice inferenceDevice = InferenceDevice.CPU)
620+
InferenceDevice inferenceDevice = InferenceDevice.Default)
621621
{
622622
if (behaviorName == m_PolicyFactory.BehaviorName &&
623623
model == m_PolicyFactory.Model &&

com.unity.ml-agents/Runtime/Inference/ModelRunner.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public ModelRunner(
8383
case InferenceDevice.Burst:
8484
executionDevice = WorkerFactory.Type.CSharpBurst;
8585
break;
86+
case InferenceDevice.Default: // fallthrough
8687
default:
8788
executionDevice = WorkerFactory.Type.CSharpBurst;
8889
break;

com.unity.ml-agents/Runtime/Policies/BarracudaPolicy.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ namespace Unity.MLAgents.Policies
1313
public enum InferenceDevice
1414
{
1515
/// <summary>
16-
/// CPU inference. Corresponds to in WorkerFactory.Type.CSharp Barracuda.
17-
/// Burst is recommended instead; this is kept for legacy compatibility.
16+
/// Default inference. This is currently the same as Burst, but may change in the future.
1817
/// </summary>
19-
CPU = 0,
18+
Default = 0,
2019

2120
/// <summary>
2221
/// GPU inference. Corresponds to WorkerFactory.Type.ComputePrecompiled in Barracuda.
@@ -27,6 +26,12 @@ public enum InferenceDevice
2726
/// CPU inference using Burst. Corresponds to WorkerFactory.Type.CSharpBurst in Barracuda.
2827
/// </summary>
2928
Burst = 2,
29+
30+
/// <summary>
31+
/// CPU inference. Corresponds to in WorkerFactory.Type.CSharp Barracuda.
32+
/// Burst is recommended instead; this is kept for legacy compatibility.
33+
/// </summary>
34+
CPU = 3,
3035
}
3136

3237
/// <summary>

com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public NNModel Model
109109
}
110110

111111
[HideInInspector, SerializeField]
112-
InferenceDevice m_InferenceDevice = InferenceDevice.Burst;
112+
InferenceDevice m_InferenceDevice = InferenceDevice.Default;
113113

114114
/// <summary>
115115
/// How inference is performed for this Agent's model.

0 commit comments

Comments
 (0)