Skip to content

Commit

Permalink
change default barracuda behavior (Unity-Technologies#5175)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Elion authored Mar 23, 2021
1 parent af6af94 commit c68ffb1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions com.unity.ml-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ interface was removed. (#5164)
- Added ML-Agents package settings. (#5027)
- Make com.unity.modules.unityanalytics an optional dependency. (#5109)
- Make com.unity.modules.physics and com.unity.modules.physics2d optional dependencies. (#5112)
- The default `InferenceDevice` is now `InferenceDevice.Default`, which is equivalent to `InferenceDevice.Burst`. If you
depend on the previous behavior, you can explicitly set the Agent's `InferenceDevice` to `InferenceDevice.CPU`. (#5175)

#### ml-agents / ml-agents-envs / gym-unity (Python)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ void NotifyAgentDone(DoneReason doneReason)
public void SetModel(
string behaviorName,
NNModel model,
InferenceDevice inferenceDevice = InferenceDevice.CPU)
InferenceDevice inferenceDevice = InferenceDevice.Default)
{
if (behaviorName == m_PolicyFactory.BehaviorName &&
model == m_PolicyFactory.Model &&
Expand Down
1 change: 1 addition & 0 deletions com.unity.ml-agents/Runtime/Inference/ModelRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public ModelRunner(
case InferenceDevice.Burst:
executionDevice = WorkerFactory.Type.CSharpBurst;
break;
case InferenceDevice.Default: // fallthrough
default:
executionDevice = WorkerFactory.Type.CSharpBurst;
break;
Expand Down
11 changes: 8 additions & 3 deletions com.unity.ml-agents/Runtime/Policies/BarracudaPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ namespace Unity.MLAgents.Policies
public enum InferenceDevice
{
/// <summary>
/// CPU inference. Corresponds to in WorkerFactory.Type.CSharp Barracuda.
/// Burst is recommended instead; this is kept for legacy compatibility.
/// Default inference. This is currently the same as Burst, but may change in the future.
/// </summary>
CPU = 0,
Default = 0,

/// <summary>
/// GPU inference. Corresponds to WorkerFactory.Type.ComputePrecompiled in Barracuda.
Expand All @@ -27,6 +26,12 @@ public enum InferenceDevice
/// CPU inference using Burst. Corresponds to WorkerFactory.Type.CSharpBurst in Barracuda.
/// </summary>
Burst = 2,

/// <summary>
/// CPU inference. Corresponds to in WorkerFactory.Type.CSharp Barracuda.
/// Burst is recommended instead; this is kept for legacy compatibility.
/// </summary>
CPU = 3,
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public NNModel Model
}

[HideInInspector, SerializeField]
InferenceDevice m_InferenceDevice = InferenceDevice.Burst;
InferenceDevice m_InferenceDevice = InferenceDevice.Default;

/// <summary>
/// How inference is performed for this Agent's model.
Expand Down

0 comments on commit c68ffb1

Please sign in to comment.