Skip to content
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

Reduce memory usage for timeseries jac computation #1001

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
pycodestyle updates
johnjasa committed Oct 16, 2023
commit fba061dc70e6b9b6c00ec5fba5a143251cee2133
Original file line number Diff line number Diff line change
@@ -159,7 +159,7 @@ def _add_output_configure(self, name, units, shape, desc='', src=None, rate=Fals
# Extend the data and indices using the CSR attributes of mat
jac_data.extend(mat.data)
jac_indices.extend(mat.indices + s * input_num_nodes)

# For every non-zero row in mat, update jac's indptr
new_indptr = mat.indptr[1:] + s * len(mat.data)
jac_indptr.extend(new_indptr)
@@ -168,7 +168,8 @@ def _add_output_configure(self, name, units, shape, desc='', src=None, rate=Fals
jac_indptr[-1] = len(jac_data)

# Construct the sparse jac matrix in CSR format
jac = sp.csr_matrix((jac_data, jac_indices, jac_indptr), shape=(output_num_nodes * size, input_num_nodes * size))
jac = sp.csr_matrix((jac_data, jac_indices, jac_indptr),
shape=(output_num_nodes * size, input_num_nodes * size))

# Now, if you want to get the row and column indices of the non-zero entries in the jac matrix:
jac_rows, jac_cols = jac.nonzero()
Original file line number Diff line number Diff line change
@@ -159,7 +159,7 @@ def _add_output_configure(self, name, units, shape, desc='', src=None, rate=Fals
# Extend the data and indices using the CSR attributes of mat
jac_data.extend(mat.data)
jac_indices.extend(mat.indices + s * input_num_nodes)

# For every non-zero row in mat, update jac's indptr
new_indptr = mat.indptr[1:] + s * len(mat.data)
jac_indptr.extend(new_indptr)
@@ -168,7 +168,8 @@ def _add_output_configure(self, name, units, shape, desc='', src=None, rate=Fals
jac_indptr[-1] = len(jac_data)

# Construct the sparse jac matrix in CSR format
jac = sp.csr_matrix((jac_data, jac_indices, jac_indptr), shape=(output_num_nodes * size, input_num_nodes * size))
jac = sp.csr_matrix((jac_data, jac_indices, jac_indptr),
shape=(output_num_nodes * size, input_num_nodes * size))

# Now, if you want to get the row and column indices of the non-zero entries in the jac matrix:
jac_rows, jac_cols = jac.nonzero()