-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[MLA-1634] Compression spec #5164
Conversation
@@ -488,34 +488,6 @@ public static UnityRLCapabilitiesProto ToProto(this UnityRLCapabilities rlCaps) | |||
}; | |||
} | |||
|
|||
internal static bool IsTrivialMapping(ISensor sensor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this logic to CompressionSpec
@@ -168,23 +155,6 @@ public void TestGetObservationProtoCapabilities() | |||
|
|||
} | |||
|
|||
[Test] | |||
public void TestIsTrivialMapping() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to com.unity.ml-agents/Tests/Editor/Sensor/CompressionSpecTests.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels so much cleaner. good stuff!
@dongruoping I forgot to tag you before - does this look OK with the channel mapping? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Left a few comments but are more like thoughts on what we can do later.
public virtual CompressionSpec GetCompressionSpec() | ||
{ | ||
return SensorCompressionType.None; | ||
return CompressionSpec.Default(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A potential improvement of this is to have a m_CompressionSpec and return that like we do with m_ObservationSpec
.
Not sure if it's worthy though given this looks pretty light weight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cached the shapes previously, because they required allocating memory. I kept that pattern for the ObservationSpec
s - it's not really necessary for performance (struct with InplaceArray, so no allocations), but it's not a bad idea since they shouldn't change at runtime. I don't think it's necessary for CompressionSpecs.
{ | ||
m_SensorCompressionType = sensorCompressionType, | ||
m_CompressedChannelMapping = compressedChannelMapping | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically you can pass in SensorCompressionType.None and non-null mapping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you can. I think I'll just make this the constructor instead of using a static method.
@@ -233,7 +227,7 @@ internal byte[] CreateEmptyPNG() | |||
} | |||
|
|||
/// <summary> | |||
/// Constrct stacked CompressedChannelMapping. | |||
/// Construct stacked CompressedChannelMapping. | |||
/// </summary> | |||
internal int[] ConstructStackedCompressedChannelMapping(ISensor wrappedSenesor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought a bit about moving this to the CompressionSpec constructor, don't think it's necessary here though.
But if one day we add more compression types it might make sense to move this so we can do something like CompressionSpec(PNG, num_layer=4, stacking=2) and have it automatically setup for different compression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think we can move more utility methods into CompressionSpec (even if they stay internal static
). I think I'll leave this here for now, but we can move it later if it makes sense (and there's another use case)
Proposed change(s)
Change ISensor interface, and remove ISparseChannelSensor interface.
Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)
Types of change(s)
Checklist
Other comments