-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[FEATURE] Modify n_rendered_envs to rendered_envs_idx #752
base: main
Are you sure you want to change the base?
Conversation
@YilingQiao do you think we can merge this after we modified add the examples using |
genesis/vis/rasterizer_context.py
Outdated
@@ -285,7 +285,7 @@ def on_rigid(self): | |||
mesh = geom.get_sdf_trimesh() | |||
else: | |||
mesh = geom.get_trimesh() | |||
geom_T = geoms_T[geom.idx][: self.n_rendered_envs] | |||
geom_T = geoms_T[geom.idx][self.rendered_envs_idx] |
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.
Beware this would trigger a copy since ‘self.rendered_envs_idx’ is not a slice but a list. No sure about the overall performance penalty it induces.
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.
I see. We should bench first...
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.
For this problem, I added a new variable called rendered_envs_idx_slice
to avoid copy list to slice in the loop
genesis/vis/rasterizer_context.py
Outdated
@@ -285,7 +285,7 @@ def on_rigid(self): | |||
mesh = geom.get_sdf_trimesh() | |||
else: | |||
mesh = geom.get_trimesh() | |||
geom_T = geoms_T[geom.idx][: self.n_rendered_envs] | |||
geom_T = geoms_T[geom.idx][self.rendered_envs_idx] |
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.
I see. We should bench first...
Yeah, I think we can merge this after incorporating the suggested changes. |
@@ -64,6 +64,7 @@ def build(self, scene): | |||
|
|||
if self.rendered_envs_idx is None: | |||
self.rendered_envs_idx = list(range(self.sim._B)) | |||
self.rendered_envs_idx_slice = slice(self.rendered_envs_idx[0], self.rendered_envs_idx[-1] + 1) |
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.
I don't think the assumption of consecutive rendered_envs_idx
is good. What we should do instead is to measure the overhead introduced by list indexing and verify it won't add more overhead compared to the current version.
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.
Definitely
@@ -208,7 +208,8 @@ def build(self, scene): | |||
self.sim = scene.sim | |||
self.visualizer = scene.visualizer | |||
if self.rendered_envs_idx is None: | |||
self.rendered_envs = list(range(self.sim._B)) | |||
self.rendered_envs_idx = list(range(self.sim._B)) | |||
self.rendered_envs_idx_slice = slice(self.rendered_envs_idx[0], self.rendered_envs_idx[-1] + 1) |
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.
I don't think the assumption of consecutive rendered_envs_idx is good.
@@ -285,7 +286,7 @@ def on_rigid(self): | |||
mesh = geom.get_sdf_trimesh() | |||
else: | |||
mesh = geom.get_trimesh() | |||
geom_T = geoms_T[geom.idx][self.rendered_envs_idx] | |||
geom_T = geoms_T[geom.idx][self.rendered_envs_idx_slice] |
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.
should keep self.rendered_envs_idx
but make sure this won't affect the performance.
@@ -312,7 +313,7 @@ def update_rigid(self, buffer_updates): | |||
geoms_T = self.sim.rigid_solver._geoms_render_T | |||
|
|||
for geom in geoms: | |||
geom_T = geoms_T[geom.idx][self.rendered_envs_idx] | |||
geom_T = geoms_T[geom.idx][self.rendered_envs_idx_slice] |
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.
should keep self.rendered_envs_idx but make sure this won't affect the performance.
Description
modify
n_rendered_envs
attribute in vis_options torendered_envs_idx
, to support specification of which env to be rendered.Motivation and Context
When training, sometimes I need to render specific env to see what happened to that env, so this specification can be useful
How Has This Been / Can This Be Tested?
modified
examples/tutorials/visualization.py
to test different idx rendered, runvisualization.py
to see the result.CI tests have been conducted locally, and there's no problem.
Screenshots (if appropriate):
render first 5 envs:

render envs with idx 10 to 14:

Checklist:
Submitting Code Changes
section of CONTRIBUTING document.