From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id qPd1EjvH6GXqVAAAqHPOHw:P1 (envelope-from ) for ; Wed, 06 Mar 2024 20:42:51 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id qPd1EjvH6GXqVAAAqHPOHw (envelope-from ) for ; Wed, 06 Mar 2024 20:42:51 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=Ti3oHA86; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1709754171; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=0Hy2AAqMKp7VKa8Ug95vfqPK+a6vNB9njk5jy1nf1zM=; b=NA32PPPO7TzCTiYjyAsW7v7hBj/zbUUk60Dimg+rlqzVsJ2z/UPE3wGBuGvFvXkmMVzHne GK9zFao4l18et90BaRcjMbmATSObXmuUzkv6vJu/CvQ+ZjFajRcIXryZeY/sSsP9mATtEu LnwQVuTR1BjPNTqpfx8FTJr54UtQOo2zhNR7cU58dKHkmLORuIYO+99Ad+4qW6hHp9TIDp NIXWq9QvJLnO5SS2D48K1uE9RW6Wi1qftoYvaxqZ3TCkEB0AeAm5V2tzO4EXWiJ7OibHa8 HI82xNCFxOUZAklHM5TeQTg2IgjK70ssUW3cqKTWNU4ivNinsYRxCxwW4oiuoQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1709754171; a=rsa-sha256; cv=none; b=IKt6ix/2qYfSt6qKuVHZTNDHoJfJAPSEo9geDGb0iLIpINXDF0h1K2eCWZzFgWauqv3VB9 ZhKc1LTEj/IWgElGKZGQPRV88bC2m8HfH/mEh9JPJMpMVF+ME6N5WudMXs5RD9lMnx1a2r dlGdObQPKXWuskXXBf2dIRUzjjNS0mnIg13eqCywME34ANZ8JyJxcw8lNXRYgHxSxIC3pv kwkSfCiZFRUKC678J5zXzaZRSbux5X9/VDWMwWsCw7Tg1n0vdrqOf18INlW7DaPRsmfrdg C8CPX2aeqOHzEydFBwoeuGI0U+SWPhAPd33CLC4KdymPuAG/P7VfaHs7Nu8yNg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=Ti3oHA86; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0AD1A6E7F6 for ; Wed, 6 Mar 2024 20:42:51 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhx9z-0002aX-TO; Wed, 06 Mar 2024 14:42:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhx9x-0002Ym-ML for guix-patches@gnu.org; Wed, 06 Mar 2024 14:42:37 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhx9x-0006Us-EK for guix-patches@gnu.org; Wed, 06 Mar 2024 14:42:37 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rhxAR-0008KT-Cc for guix-patches@gnu.org; Wed, 06 Mar 2024 14:43:07 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#69591] [PATCH 25/31] gnu: Add qnnpack-pytorch. Resent-From: David Elsing Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 06 Mar 2024 19:43:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69591 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69591@debbugs.gnu.org Cc: David Elsing Received: via spool by 69591-submit@debbugs.gnu.org id=B69591.170975415531849 (code B ref 69591); Wed, 06 Mar 2024 19:43:07 +0000 Received: (at 69591) by debbugs.gnu.org; 6 Mar 2024 19:42:35 +0000 Received: from localhost ([127.0.0.1]:51581 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhx9t-0008HV-UM for submit@debbugs.gnu.org; Wed, 06 Mar 2024 14:42:35 -0500 Received: from mout02.posteo.de ([185.67.36.66]:51563) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhx97-0008AS-Hc for 69591@debbugs.gnu.org; Wed, 06 Mar 2024 14:41:49 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 20D00240105 for <69591@debbugs.gnu.org>; Wed, 6 Mar 2024 20:41:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1709754074; bh=uUiv7+ui0AaFAyriYNuNBLb5IJgTDPBqVn+9osV2/rQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=Ti3oHA86mrZtPFKcql/b7IGaoaOX+lbNOdwDsGb0mMWJw+BCJL96VEBWJ22yJ1cbZ RM+CaD6eKW0vq9sr3ot84UbqaQBMESHEXbXOyro1Zz3b9a66a6rmstvhwZ328Cbk3a pP0fkQnsvW0QO6G0kL95HHYrXm6s56un5rcmvuqpAifXTXHJeaet7Z6ZHxe9sz6ADK 2ONv09NyG2D3wPH46srCnjhmKejddLo7TuahvI1kFFT0HY1cCHzKvTL+tsPx4k0GlV KYvBBlrJ2t5pjqB0NC74KcsXcoZDtUXu6F0iM+RG5DhH94WjqNIdq2ZPG3hT1OJlXy S2oS7tWKD4CWw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TqjV153Jkz6tyd; Wed, 6 Mar 2024 20:41:13 +0100 (CET) From: David Elsing Date: Wed, 6 Mar 2024 19:40:31 +0000 Message-ID: <20240306194037.17992-25-david.elsing@posteo.net> In-Reply-To: <20240306193725.17463-1-david.elsing@posteo.net> References: <20240306193725.17463-1-david.elsing@posteo.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -2.37 X-Spam-Score: -2.37 X-Migadu-Queue-Id: 0AD1A6E7F6 X-Migadu-Scanner: mx11.migadu.com X-TUID: Mqsl6TBPG0P2 This is an internal fork of QNNPACK in the PyTorch source tree. * gnu/packages/machine-learning.scm (%python-pytorch-version): New variable. (%python-pytorch-src): New variable. (qnnpack-pytorch): New variable. --- gnu/packages/machine-learning.scm | 127 ++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 0cab068fbd..eed649f118 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -4310,6 +4310,133 @@ (define-public ideep-pytorch PyTorch.") (license license:expat))) +(define %python-pytorch-version "2.2.1") + +(define %python-pytorch-src + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/pytorch/pytorch") + (commit (string-append "v" %python-pytorch-version)))) + (file-name (git-file-name "python-pytorch" %python-pytorch-version)) + (sha256 + (base32 + "03mm0pwwb5lxdsmmiw3cch9fijgjw81kmmc4ln9rlyazkm7l1r48")) + (modules '((guix build utils))) + (snippet + '(begin + ;; Bundled or unused code + (for-each + (lambda (dir) + (when (file-exists? dir) + (delete-file-recursively dir))) + '("android" + "aten/src/ATen/native/cuda/cutlass_extensions" + "aten/src/ATen/native/quantized/cpu/qnnpack" + "caffe2/mobile/contrib/libopencl-stub" + "caffe2/mobile/contrib/libvulkan-stub" + "third_party")) + + ;; Autogenerated files + (for-each + delete-file + '("aten/src/ATen/nnapi/nnapi_wrapper.cpp" + "aten/src/ATen/nnapi/nnapi_wrapper.h" + "caffe2/mobile/contrib/ios/mpscnn/mpscnn_kernels.h" + "caffe2/proto/caffe2_legacy_pb2.pyi" + "caffe2/proto/caffe2_pb2.pyi" + "caffe2/proto/hsm_pb2.pyi" + "caffe2/proto/metanet_pb2.pyi" + "caffe2/proto/predictor_consts_pb2.pyi" + "caffe2/proto/prof_dag_pb2.pyi" + "caffe2/proto/torch_pb2.pyi" + ;; These files contain just lists of floating point values and + ;; might be as well hand-written. + ;; "test/cpp/api/init_baseline.h" + ;; "test/cpp/api/optim_baseline.h" + "test/mobile/test_upgrader_bytecode_table_example.cpp" + "torch/csrc/jit/mobile/upgrader_mobile.cpp" + "torch/csrc/jit/runtime/decomposition_registry_util.cpp" + "torch/csrc/jit/runtime/serialized_shape_function_registry.cpp" + "torch/csrc/jit/tensorexpr/external_functions_codegen.cpp" + "torch/csrc/jit/serialization/mobile_bytecode_generated.h")) + (delete-file-recursively ".github") + (for-each + (lambda (dir) + (for-each + delete-file + (find-files dir "\\.cu$"))) + '("aten/src/ATen/native/transformers/cuda/flash_attn/kernels" + "aten/src/ATen/native/transformers/cuda/mem_eff_attention/kernels")))))) + +(define-public qnnpack-pytorch + (package + (inherit qnnpack) + (name "qnnpack-pytorch") + (version (string-append "pytorch-" %python-pytorch-version)) + (source + (origin + (inherit %python-pytorch-src) + (patches '()) + (modules '((guix build utils) + (srfi srfi-26) + (ice-9 ftw))) + (snippet + '(begin + (rename-file "aten/src/ATen/native/quantized/cpu/qnnpack" + "../qnnpack") + (let ((outdir (getcwd))) + (chdir "..") + (rename-file outdir "dummy") + (rename-file "qnnpack" outdir) + (chdir outdir) + (delete-file-recursively "deps")))))) + (arguments + (substitute-keyword-arguments (package-arguments qnnpack) + ((#:phases phases #~%standard-phases) + #~(modify-phases %standard-phases + (add-after 'unpack 'patch-cmake + (lambda _ + (substitute* "CMakeLists.txt" + (("project\\(.*" orig) + (apply + string-append + orig "\n" + (map (lambda (name) + (string-append + "option(" name " \"\" ON)\n")) + '("USE_SYSTEM_CPUINFO" "USE_SYSTEM_FP16" "USE_SYSTEM_FXDIV" + "USE_SYSTEM_PSIMD" "USE_SYSTEM_PTHREADPOOL")))) + (("if.*SOURCE_DIR.*") + "if(FALSE)\n") + (("if\\(NOT TARGET (clog|gtest|benchmark).*") + "if(FALSE)\n") + (("target_link_libraries.*(fxdiv|psimd|fp16)\\).*") + "") + (("(target_link_libraries.*) fp16 (.*)" _ before after) + (string-append before " " after))))) + (add-after 'unpack 'fix-cstring-include + (lambda _ + (substitute* "include/pack_block_sparse.h" + (("#include.*.*" orig) + (string-append orig "\n#include \n"))))) + (add-after 'install 'install-missing-headers + (lambda _ + (for-each + (lambda (name) + (install-file (string-append "../source/include/" name) + (string-append #$output "/include"))) + '("pack_block_sparse.h" + "pytorch_qnnpack.h" + "qnnpack_func.h")) + (copy-recursively + "../source/src/qnnpack" + (string-append #$output "/include/qnnpack")))))) + ;; Some tests occasionally fail on i686 due to floating point rounding. + ((#:tests? _ #t) + (not (string-prefix? "i686" (or (%current-target-system) + (%current-system))))))))) + ;; Please also update python-torchvision when updating this package. (define-public python-pytorch (package -- 2.41.0