{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/benchmarking-the-linear-algebra-awareness-of","title":"Benchmarking the Linear Algebra Awareness of TensorFlow and PyTorch","arxiv_id":"2202.09888","date":"2022-02-20","proceeding":null,"authors":["Aravind Sankaran","Navid Akbari Alashti","Christos Psarras","Paolo Bientinesi"],"abstract":"Linear algebra operations, which are ubiquitous in machine learning, form major performance bottlenecks. The High-Performance Computing community invests significant effort in the development of architecture-specific optimized kernels, such as those provided by the BLAS and LAPACK libraries, to speed up linear algebra operations. However, end users are progressively less likely to go through the error prone and time-consuming process of directly using said kernels; instead, frameworks such as TensorFlow (TF) and PyTorch (PyT), which facilitate the development of machine learning applications, are becoming more and more popular. Although such frameworks link to BLAS and LAPACK, it is not clear whether or not they make use of linear algebra knowledge to speed up computations. For this reason, in this paper we develop benchmarks to investigate the linear algebra optimization capabilities of TF and PyT. Our analyses reveal that a number of linear algebra optimizations are still missing; for instance, reducing the number of scalar operations by applying the distributive law, and automatically identifying the optimal parenthesization of a matrix chain. In this work, we focus on linear algebra computations in TF and PyT; we both expose opportunities for performance enhancement to the benefit of the developers of the frameworks and provide end users with guidelines on how to achieve performance gains.","url_abs":"https://arxiv.org/abs/2202.09888v1","url_pdf":"https://arxiv.org/pdf/2202.09888v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"benchmarking-the-linear-algebra-awareness-of","repo_url":"https://github.com/as641651/linearalgebra-awareness-benchmark","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"tf","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"benchmarking-the-linear-algebra-awareness-of","repo_url":"https://github.com/chrispsa/lamp_benchmark","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"tasks":[{"task_slug":"benchmarking","task_name":"Benchmarking"}],"methods":[{"method_slug":"speed","method_name":"SPEED"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2202.09888","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2202.09888"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/as641651/linearalgebra-awareness-benchmark","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/chrispsa/lamp_benchmark","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"summary":{"unverified":19},"by_repo_kind":{"official":{"samples":18,"ran":0,"repositories":1},"listed":{"samples":1,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"5f6adb6e03177270","entry":"benchmark","repo":"chrispsa/lamp_benchmark","repo_kind":"listed","path":"python/numpy/benchmarker.py","file_url":"https://github.com/chrispsa/lamp_benchmark/blob/HEAD/python/numpy/benchmarker.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"5f6adb6e03177270"}},{"code_sha256_prefix":"22a6a516d56403ba","entry":"format_cutoff_results_md","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/prepare_report.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/prepare_report.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"22a6a516d56403ba"}},{"code_sha256_prefix":"126ee0390b236079","entry":"format_floats_recursive","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/prepare_report.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/prepare_report.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"126ee0390b236079"}},{"code_sha256_prefix":"c5b298b754b9fb33","entry":"linalg_matmul","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/am_blocked.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/am_blocked.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c5b298b754b9fb33"}},{"code_sha256_prefix":"227aac16367e955a","entry":"operator","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/am_blocked.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/am_blocked.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"227aac16367e955a"}},{"code_sha256_prefix":"16e19eafa21d1903","entry":"ref_negative","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/am_distributivity1.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/am_distributivity1.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"16e19eafa21d1903"}},{"code_sha256_prefix":"2d2a55983a86dae7","entry":"ref_negative","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/am_distributivity2.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/am_distributivity2.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2d2a55983a86dae7"}},{"code_sha256_prefix":"5d516c141faae762","entry":"ref_negative","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/am_transpose.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/am_transpose.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5d516c141faae762"}},{"code_sha256_prefix":"953e2ef4ffaf77b2","entry":"ref_negative","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/cm_partial_op_prod.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/cm_partial_op_prod.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"953e2ef4ffaf77b2"}},{"code_sha256_prefix":"11d2511028f02081","entry":"ref_negative","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/cm_partial_op_sum.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/cm_partial_op_sum.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"11d2511028f02081"}},{"code_sha256_prefix":"36b39fcbf80f56e4","entry":"ref_positive","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/am_blocked.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/am_blocked.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"36b39fcbf80f56e4"}},{"code_sha256_prefix":"1529084dacf58e68","entry":"ref_positive","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/am_distributivity1.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/am_distributivity1.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1529084dacf58e68"}},{"code_sha256_prefix":"c73ed459f46b94af","entry":"ref_positive","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/am_distributivity2.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/am_distributivity2.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c73ed459f46b94af"}},{"code_sha256_prefix":"54d5a84e0d761703","entry":"ref_positive","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/am_transpose.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/am_transpose.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"54d5a84e0d761703"}},{"code_sha256_prefix":"40c15acbfeef17da","entry":"ref_positive","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/cm_loops.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/cm_loops.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"40c15acbfeef17da"}},{"code_sha256_prefix":"d792bafba67d2899","entry":"ref_positive","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/cm_partial_op_prod.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/cm_partial_op_prod.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d792bafba67d2899"}},{"code_sha256_prefix":"191ebcca1eb39dd6","entry":"ref_positive","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/cm_partial_op_sum.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/cm_partial_op_sum.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"191ebcca1eb39dd6"}},{"code_sha256_prefix":"ef0d2ee2886a35a8","entry":"ref_positive","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/cse_addition.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/cse_addition.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ef0d2ee2886a35a8"}},{"code_sha256_prefix":"bf7659c80bf0ef0b","entry":"ref_positive","repo":"as641651/linearalgebra-awareness-benchmark","repo_kind":"official","path":"laab_python/src/PyTorch/v2-cpu/cse_matmul_no_paranthesis.py","file_url":"https://github.com/as641651/linearalgebra-awareness-benchmark/blob/HEAD/laab_python/src/PyTorch/v2-cpu/cse_matmul_no_paranthesis.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"bf7659c80bf0ef0b"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}