-
Notifications
You must be signed in to change notification settings - Fork 4.3k
In-Editor Analytics for inference #4677
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
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
0a3b1c2
WIP
0c4c9d8
WIP
99a5325
Merge remote-tracking branch 'origin/master' into MLA-1545-inference-…
ea8dec8
action and sensor events
333cc87
send from barracudapolicy instead, keep set of models logged
2db88ff
cleanup, undo some changes
b7748da
model memory and hashing
362ed03
Merge remote-tracking branch 'origin/master' into MLA-1545-inference-…
0f24a16
rename event and add [Serialize]
59c4b38
make non-editor friendly
405c4ef
update hashing - use Hash128, always limit number of floats
140632e
more observation fields, use struct for dimensions
add10c4
docstrings
e85fd50
more docstrings
8c07e5e
update docstrings
9b3ece7
fix builds, add tests
2ba6d35
fix 2020 compile
79c4741
Merge remote-tracking branch 'origin' into MLA-1545-inference-analytics
b577ec2
Uncomment EditorAnalytics.SendEventWithLimit
3b7f742
changelog:
b9a4aca
better changelog
de08a28
hash behavior name
c69589e
update analytics notice
b8cec80
readme too
f4ebc34
Merge remote-tracking branch 'origin/master' into MLA-1545-inference-…
6a2af46
Merge remote-tracking branch 'origin/master' into MLA-1545-inference-…
c958b8a
fix unit test (path changed on merge)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Unity.MLAgents.Actuators; | ||
using Unity.MLAgents.Sensors; | ||
|
||
namespace Unity.MLAgents.Analytics | ||
{ | ||
internal struct InferenceEvent | ||
{ | ||
/// <summary> | ||
/// Hash of the BehaviorName. | ||
/// </summary> | ||
public string BehaviorName; | ||
public string BarracudaModelSource; | ||
public string BarracudaModelVersion; | ||
public string BarracudaModelProducer; | ||
public string BarracudaPackageVersion; | ||
/// <summary> | ||
/// Whether inference is performed on CPU (0) or GPU (1). | ||
/// </summary> | ||
public int InferenceDevice; | ||
public List<EventObservationSpec> ObservationSpecs; | ||
public EventActionSpec ActionSpec; | ||
public int MemorySize; | ||
public long TotalWeightSizeBytes; | ||
public string ModelHash; | ||
} | ||
|
||
/// <summary> | ||
/// Simplified version of ActionSpec struct for use in analytics | ||
/// </summary> | ||
[Serializable] | ||
internal struct EventActionSpec | ||
{ | ||
public int NumContinuousActions; | ||
public int NumDiscreteActions; | ||
public int[] BranchSizes; | ||
|
||
public static EventActionSpec FromActionSpec(ActionSpec actionSpec) | ||
{ | ||
var branchSizes = actionSpec.BranchSizes ?? Array.Empty<int>(); | ||
return new EventActionSpec | ||
{ | ||
NumContinuousActions = actionSpec.NumContinuousActions, | ||
NumDiscreteActions = actionSpec.NumDiscreteActions, | ||
BranchSizes = branchSizes, | ||
}; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Information about one dimension of an observation. | ||
/// </summary> | ||
[Serializable] | ||
internal struct EventObservationDimensionInfo | ||
chriselion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
public int Size; | ||
public int Flags; | ||
} | ||
|
||
/// <summary> | ||
/// Simplified summary of Agent observations for use in analytics | ||
/// </summary> | ||
[Serializable] | ||
internal struct EventObservationSpec | ||
{ | ||
public string SensorName; | ||
public string CompressionType; | ||
public EventObservationDimensionInfo[] DimensionInfos; | ||
|
||
public static EventObservationSpec FromSensor(ISensor sensor) | ||
{ | ||
var shape = sensor.GetObservationShape(); | ||
var dimInfos = new EventObservationDimensionInfo[shape.Length]; | ||
for (var i = 0; i < shape.Length; i++) | ||
{ | ||
dimInfos[i].Size = shape[i]; | ||
// TODO copy flags when we have them | ||
} | ||
|
||
return new EventObservationSpec | ||
{ | ||
SensorName = sensor.GetName(), | ||
CompressionType = sensor.GetCompressionType().ToString(), | ||
DimensionInfos = dimInfos, | ||
}; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.