diff options
author | Yi Kong <yikong@google.com> | 2022-02-25 16:41:05 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-02-25 16:41:05 +0000 |
commit | bc0f5df265caa21a2120c22453655a7fcc941991 (patch) | |
tree | fb979fb4cf4f8052c8cc66b1ec9516d91fcd859b /debug | |
parent | 8fd413e275f78a4c240f1442ce5cf77c73a20a55 (diff) | |
parent | 7cb50013986f04dce5fac87bebf319bb8db37a36 (diff) | |
download | eigen-android13-qpr3-s6-release.tar.gz |
Merge changes Iee153445,Iee274471 am: 79df15ea88 am: 10f298fc41 am: 7cb5001398t_frc_odp_330442040t_frc_odp_330442000t_frc_ase_330444010android-wear-13.0.0-gpl_r3android-wear-13.0.0-gpl_r2android-wear-13.0.0-gpl_r1android-vts-13.0_r8android-vts-13.0_r7android-vts-13.0_r6android-vts-13.0_r5android-vts-13.0_r4android-vts-13.0_r3android-vts-13.0_r2android-t-qpr3-beta-3-gplandroid-t-qpr3-beta-1-gplandroid-t-qpr2-beta-3-gplandroid-t-qpr2-beta-2-gplandroid-t-qpr1-beta-3-gplandroid-t-qpr1-beta-1-gplandroid-cts-13.0_r8android-cts-13.0_r7android-cts-13.0_r6android-cts-13.0_r5android-cts-13.0_r4android-cts-13.0_r3android-cts-13.0_r2android-13.0.0_r83android-13.0.0_r82android-13.0.0_r81android-13.0.0_r80android-13.0.0_r79android-13.0.0_r78android-13.0.0_r77android-13.0.0_r76android-13.0.0_r75android-13.0.0_r74android-13.0.0_r73android-13.0.0_r72android-13.0.0_r71android-13.0.0_r70android-13.0.0_r69android-13.0.0_r68android-13.0.0_r67android-13.0.0_r66android-13.0.0_r65android-13.0.0_r64android-13.0.0_r63android-13.0.0_r62android-13.0.0_r61android-13.0.0_r60android-13.0.0_r59android-13.0.0_r58android-13.0.0_r57android-13.0.0_r56android-13.0.0_r55android-13.0.0_r54android-13.0.0_r53android-13.0.0_r52android-13.0.0_r51android-13.0.0_r50android-13.0.0_r49android-13.0.0_r48android-13.0.0_r47android-13.0.0_r46android-13.0.0_r45android-13.0.0_r44android-13.0.0_r43android-13.0.0_r42android-13.0.0_r41android-13.0.0_r40android-13.0.0_r39android-13.0.0_r38android-13.0.0_r37android-13.0.0_r36android-13.0.0_r35android-13.0.0_r34android-13.0.0_r33android-13.0.0_r32android-13.0.0_r30android-13.0.0_r29android-13.0.0_r28android-13.0.0_r27android-13.0.0_r24android-13.0.0_r23android-13.0.0_r22android-13.0.0_r21android-13.0.0_r20android-13.0.0_r19android-13.0.0_r18android-13.0.0_r17android-13.0.0_r16aml_go_odp_330912000aml_go_ads_330915100aml_go_ads_330915000aml_go_ads_330913000android13-tests-releaseandroid13-tests-devandroid13-qpr3-s9-releaseandroid13-qpr3-s8-releaseandroid13-qpr3-s7-releaseandroid13-qpr3-s6-releaseandroid13-qpr3-s5-releaseandroid13-qpr3-s4-releaseandroid13-qpr3-s3-releaseandroid13-qpr3-s2-releaseandroid13-qpr3-s14-releaseandroid13-qpr3-s13-releaseandroid13-qpr3-s12-releaseandroid13-qpr3-s11-releaseandroid13-qpr3-s10-releaseandroid13-qpr3-s1-releaseandroid13-qpr3-releaseandroid13-qpr3-c-s8-releaseandroid13-qpr3-c-s7-releaseandroid13-qpr3-c-s6-releaseandroid13-qpr3-c-s5-releaseandroid13-qpr3-c-s4-releaseandroid13-qpr3-c-s3-releaseandroid13-qpr3-c-s2-releaseandroid13-qpr3-c-s12-releaseandroid13-qpr3-c-s11-releaseandroid13-qpr3-c-s10-releaseandroid13-qpr3-c-s1-releaseandroid13-qpr2-s9-releaseandroid13-qpr2-s8-releaseandroid13-qpr2-s7-releaseandroid13-qpr2-s6-releaseandroid13-qpr2-s5-releaseandroid13-qpr2-s3-releaseandroid13-qpr2-s2-releaseandroid13-qpr2-s12-releaseandroid13-qpr2-s11-releaseandroid13-qpr2-s10-releaseandroid13-qpr2-s1-releaseandroid13-qpr2-releaseandroid13-qpr2-b-s1-releaseandroid13-qpr1-s8-releaseandroid13-qpr1-s7-releaseandroid13-qpr1-s6-releaseandroid13-qpr1-s5-releaseandroid13-qpr1-s4-releaseandroid13-qpr1-s3-releaseandroid13-qpr1-s2-releaseandroid13-qpr1-s1-releaseandroid13-qpr1-releaseandroid13-mainline-go-adservices-releaseandroid13-frc-odp-releaseandroid13-devandroid13-d4-s2-releaseandroid13-d4-s1-releaseandroid13-d4-releaseandroid13-d3-s1-releaseandroid13-d2-releaseandroid-wear-13.0.0-gpl_r1
Original change: https://android-review.googlesource.com/c/platform/external/eigen/+/1999079
Change-Id: I4c76dc5ddc7fb0ae9fc42436f28bd8bf9de50a97
Diffstat (limited to 'debug')
-rw-r--r-- | debug/gdb/printers.py | 168 | ||||
-rw-r--r-- | debug/msvc/eigen_autoexp_part.dat | 2 |
2 files changed, 135 insertions, 35 deletions
diff --git a/debug/gdb/printers.py b/debug/gdb/printers.py index 0d67a5f99..24961d115 100644 --- a/debug/gdb/printers.py +++ b/debug/gdb/printers.py @@ -10,8 +10,7 @@ # Pretty printers for Eigen::Matrix # This is still pretty basic as the python extension to gdb is still pretty basic. -# It cannot handle complex eigen types and it doesn't support any of the other eigen types -# Such as quaternion or some other type. +# It cannot handle complex eigen types and it doesn't support many of the other eigen types # This code supports fixed size as well as dynamic size matrices # To use it: @@ -29,7 +28,45 @@ import gdb import re import itertools +from bisect import bisect_left +# Basic row/column iteration code for use with Sparse and Dense matrices +class _MatrixEntryIterator(object): + + def __init__ (self, rows, cols, rowMajor): + self.rows = rows + self.cols = cols + self.currentRow = 0 + self.currentCol = 0 + self.rowMajor = rowMajor + + def __iter__ (self): + return self + + def next(self): + return self.__next__() # Python 2.x compatibility + + def __next__(self): + row = self.currentRow + col = self.currentCol + if self.rowMajor == 0: + if self.currentCol >= self.cols: + raise StopIteration + + self.currentRow = self.currentRow + 1 + if self.currentRow >= self.rows: + self.currentRow = 0 + self.currentCol = self.currentCol + 1 + else: + if self.currentRow >= self.rows: + raise StopIteration + + self.currentCol = self.currentCol + 1 + if self.currentCol >= self.cols: + self.currentCol = 0 + self.currentRow = self.currentRow + 1 + + return (row, col) class EigenMatrixPrinter: "Print Eigen Matrix or Array of some kind" @@ -77,42 +114,15 @@ class EigenMatrixPrinter: self.data = self.data['array'] self.data = self.data.cast(self.innerType.pointer()) - class _iterator: + class _iterator(_MatrixEntryIterator): def __init__ (self, rows, cols, dataPtr, rowMajor): - self.rows = rows - self.cols = cols - self.dataPtr = dataPtr - self.currentRow = 0 - self.currentCol = 0 - self.rowMajor = rowMajor - - def __iter__ (self): - return self + super(EigenMatrixPrinter._iterator, self).__init__(rows, cols, rowMajor) - def next(self): - return self.__next__() # Python 2.x compatibility + self.dataPtr = dataPtr def __next__(self): - row = self.currentRow - col = self.currentCol - if self.rowMajor == 0: - if self.currentCol >= self.cols: - raise StopIteration - - self.currentRow = self.currentRow + 1 - if self.currentRow >= self.rows: - self.currentRow = 0 - self.currentCol = self.currentCol + 1 - else: - if self.currentRow >= self.rows: - raise StopIteration - - self.currentCol = self.currentCol + 1 - if self.currentCol >= self.cols: - self.currentCol = 0 - self.currentRow = self.currentRow + 1 - + row, col = super(EigenMatrixPrinter._iterator, self).__next__() item = self.dataPtr.dereference() self.dataPtr = self.dataPtr + 1 @@ -129,6 +139,95 @@ class EigenMatrixPrinter: def to_string(self): return "Eigen::%s<%s,%d,%d,%s> (data ptr: %s)" % (self.variety, self.innerType, self.rows, self.cols, "RowMajor" if self.rowMajor else "ColMajor", self.data) +class EigenSparseMatrixPrinter: + "Print an Eigen SparseMatrix" + + def __init__(self, val): + "Extract all the necessary information" + + type = val.type + if type.code == gdb.TYPE_CODE_REF: + type = type.target() + self.type = type.unqualified().strip_typedefs() + tag = self.type.tag + regex = re.compile('\<.*\>') + m = regex.findall(tag)[0][1:-1] + template_params = m.split(',') + template_params = [x.replace(" ", "") for x in template_params] + + self.options = 0 + if len(template_params) > 1: + self.options = template_params[1]; + + self.rowMajor = (int(self.options) & 0x1) + + self.innerType = self.type.template_argument(0) + + self.val = val + + self.data = self.val['m_data'] + self.data = self.data.cast(self.innerType.pointer()) + + class _iterator(_MatrixEntryIterator): + def __init__ (self, rows, cols, val, rowMajor): + super(EigenSparseMatrixPrinter._iterator, self).__init__(rows, cols, rowMajor) + + self.val = val + + def __next__(self): + + row, col = super(EigenSparseMatrixPrinter._iterator, self).__next__() + + # repeat calculations from SparseMatrix.h: + outer = row if self.rowMajor else col + inner = col if self.rowMajor else row + start = self.val['m_outerIndex'][outer] + end = ((start + self.val['m_innerNonZeros'][outer]) if self.val['m_innerNonZeros'] else + self.val['m_outerIndex'][outer+1]) + + # and from CompressedStorage.h: + data = self.val['m_data'] + if start >= end: + item = 0 + elif (end > start) and (inner == data['m_indices'][end-1]): + item = data['m_values'][end-1] + else: + # create Python index list from the target range within m_indices + indices = [data['m_indices'][x] for x in range(int(start), int(end)-1)] + # find the index with binary search + idx = int(start) + bisect_left(indices, inner) + if ((idx < end) and (data['m_indices'][idx] == inner)): + item = data['m_values'][idx] + else: + item = 0 + + return ('[%d,%d]' % (row, col), item) + + def children(self): + if self.data: + return self._iterator(self.rows(), self.cols(), self.val, self.rowMajor) + + return iter([]) # empty matrix, for now + + + def rows(self): + return self.val['m_outerSize'] if self.rowMajor else self.val['m_innerSize'] + + def cols(self): + return self.val['m_innerSize'] if self.rowMajor else self.val['m_outerSize'] + + def to_string(self): + + if self.data: + status = ("not compressed" if self.val['m_innerNonZeros'] else "compressed") + else: + status = "empty" + dimensions = "%d x %d" % (self.rows(), self.cols()) + layout = "row" if self.rowMajor else "column" + + return "Eigen::SparseMatrix<%s>, %s, %s major, %s" % ( + self.innerType, dimensions, layout, status ) + class EigenQuaternionPrinter: "Print an Eigen Quaternion" @@ -156,7 +255,7 @@ class EigenQuaternionPrinter: return self def next(self): - return self.__next__() # Python 2.x compatibility + return self.__next__() # Python 2.x compatibility def __next__(self): element = self.currentElement @@ -180,6 +279,7 @@ class EigenQuaternionPrinter: def build_eigen_dictionary (): pretty_printers_dict[re.compile('^Eigen::Quaternion<.*>$')] = lambda val: EigenQuaternionPrinter(val) pretty_printers_dict[re.compile('^Eigen::Matrix<.*>$')] = lambda val: EigenMatrixPrinter("Matrix", val) + pretty_printers_dict[re.compile('^Eigen::SparseMatrix<.*>$')] = lambda val: EigenSparseMatrixPrinter(val) pretty_printers_dict[re.compile('^Eigen::Array<.*>$')] = lambda val: EigenMatrixPrinter("Array", val) def register_eigen_printers(obj): diff --git a/debug/msvc/eigen_autoexp_part.dat b/debug/msvc/eigen_autoexp_part.dat index 07aa43739..35ef5807c 100644 --- a/debug/msvc/eigen_autoexp_part.dat +++ b/debug/msvc/eigen_autoexp_part.dat @@ -14,7 +14,7 @@ ; * - Eigen::Matrix<*,-1,+,*,*,*>
; * - Eigen::Matrix<*,+,+,*,*,*>
; *
-; * Matrices are displayed properly independantly of the memory
+; * Matrices are displayed properly independently of the memory
; * alignment (RowMajor vs. ColMajor).
; *
; * This file is distributed WITHOUT ANY WARRANTY. Please ensure
|