Skip to content

Change default barracuda behavior #5175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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