From 6a1031849752936e2183c8f103b605d2179fb089 Mon Sep 17 00:00:00 2001 From: lin-hitonami Date: Fri, 16 Jun 2023 17:19:04 +0800 Subject: [PATCH] Update base for Update on "[lang] Record the element_type of the AnyArray" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### 🤖 Generated by Copilot at 0176872 ### Summary 📝🔬🆕 Improved type handling and gradient computation of `AnyArray` arguments in Taichi kernels and functions. Added `element_type` parameter to `AnyArray` constructor and `decl_ndarray_arg` function. > _To declare an array argument_ > _We pass the element type along_ > _This helps `AnyArray`_ > _To know what to say_ > _When it calls `get_type` or `grad`_ ### Walkthrough * Add `element_type` argument to `AnyArray` constructor and store it as an attribute ([link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-2e623ee0b0eec1b200fead36c0627a3c54738f6d83d79757398dc67decc01da8L18-R20), [link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-575efc738df7b1202370c2531ec82232dc7f287b2bec4999af03ef40da4f5deeL111-R111)) * Return stored `element_type` in `AnyArray.get_type` method instead of inferring from pointer ([link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-2e623ee0b0eec1b200fead36c0627a3c54738f6d83d79757398dc67decc01da8L36-R37)) * Pass stored `element_type` to `AnyArray` constructor in `AnyArray.grad` method to preserve type information in gradient array ([link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-2e623ee0b0eec1b200fead36c0627a3c54738f6d83d79757398dc67decc01da8L43-R44)) [ghstack-poisoned]