def fetch_tensor_value(self, tensor_location: TensorLocation) -> np.ndarray: event_file_name = tensor_location.event_file_name if not self._is_event_file_present(event_file_name): self.event_file_present_loop(tensor_location) start = tensor_location.start_idx length = tensor_location.length request = [ReadObjectRequest(event_file_name, int(start), int(length))] res = S3Handler.get_objects(request) tr = TensorReader(res[0]) # Access the only element in res tensor_tuple = list(tr.read_tensors())[0] # Access the only element in the list tensor_name, step, tensor_data, mode, mode_step = tensor_tuple return tensor_data
def fetch_tensor_value(self, tensor_location: TensorLocation) -> np.ndarray: event_file_name = tensor_location.event_file_name if not self._is_event_file_present(event_file_name): self.event_file_present_loop(tensor_location) start = tensor_location.start_idx length = tensor_location.length with open(event_file_name, "rb") as event_file: event_file.seek(start) tensor_object = event_file.read(length) tr = TensorReader(tensor_object) tensor_tuple = list(tr.read_tensors())[0] # Access the only element in the list tensor_name, step, tensor_data, mode, mode_step = tensor_tuple return tensor_data