modeld: skip redundant cast, reshape, and flatten (#35735)

* skip redundant cast, reshape, and flatten

* accidentally deleted a newline lol
pull/35793/head
Jimmy 2 months ago committed by GitHub
parent a931ed5c15
commit 7e0d3c22f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      selfdrive/modeld/dmonitoringmodeld.py
  2. 4
      selfdrive/modeld/modeld.py

@ -93,7 +93,7 @@ class ModelState:
self.tensor_inputs['input_img'] = Tensor(self.frame.buffer_from_cl(input_img_cl).reshape((1, MODEL_WIDTH*MODEL_HEIGHT)), dtype=dtypes.uint8).realize()
output = self.model_run(**self.tensor_inputs).numpy().flatten()
output = self.model_run(**self.tensor_inputs).contiguous().realize().uop.base.buffer.numpy()
t2 = time.perf_counter()
return output, t2 - t1

@ -163,14 +163,14 @@ class ModelState:
if prepare_only:
return None
self.vision_output = self.vision_run(**self.vision_inputs).numpy().flatten()
self.vision_output = self.vision_run(**self.vision_inputs).contiguous().realize().uop.base.buffer.numpy()
vision_outputs_dict = self.parser.parse_vision_outputs(self.slice_outputs(self.vision_output, self.vision_output_slices))
self.full_features_buffer[0,:-1] = self.full_features_buffer[0,1:]
self.full_features_buffer[0,-1] = vision_outputs_dict['hidden_state'][0, :]
self.numpy_inputs['features_buffer'][:] = self.full_features_buffer[0, self.temporal_idxs]
self.policy_output = self.policy_run(**self.policy_inputs).numpy().flatten()
self.policy_output = self.policy_run(**self.policy_inputs).contiguous().realize().uop.base.buffer.numpy()
policy_outputs_dict = self.parser.parse_policy_outputs(self.slice_outputs(self.policy_output, self.policy_output_slices))
# TODO model only uses last value now

Loading…
Cancel
Save