gemini-code-assist[bot] commented on code in PR #18867: URL: https://github.com/apache/tvm/pull/18867#discussion_r2879603101
########## docker/install/ubuntu_install_androidsdk.sh: ########## @@ -0,0 +1,114 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +. /etc/profile + +set -o errexit -o nounset +set -o pipefail + +ANDROID_HOME=/opt/android-sdk-linux +ASDKTOOLS_HOME=/opt/android-sdk-tools +ASDKTOOLS_VERSION=3859397 +ASDKTOOLS_SHA256=444e22ce8ca0f67353bda4b85175ed3731cae3ffa695ca18119cbacef1c1bea0 +COMMANDLINETOOLS_VERSION=11076708 +COMMANDLINETOOLS_SHA256=2d2d50857e4eb553af5a6dc3ad507a17adf43d115264b1afc116f95c92e5e258 + +ANDROID_NDK_VERSION=26.3.11579264 +CMAKE_VERSION=3.6.4111459 +BUILD_TOOLS_VERSION=34.0.0 +ANDROID_PLATFORM=27 +ANDROID_NDK_MAJOR=26 + +if [ $# -gt 0 ] ; then + ANDROID_NDK_VERSION=$1 + ANDROID_NDK_MAJOR=`echo $1 | cut -d "." -f1` +fi +if [ $# -gt 1 ] ; then + CMAKE_VERSION=$2 +fi +if [ $# -gt 2 ] ; then + BUILD_TOOLS_VERSION=$3 +fi +if [ $# -gt 3 ] ; then + ANDROID_PLATFORM=$4 +fi + +echo "NDK Version: ${ANDROID_NDK_VERSION}" +echo "NDK Major : ${ANDROID_NDK_MAJOR}" +echo "Cmake Version: ${CMAKE_VERSION}" +echo "Build Tools: ${BUILD_TOOLS_VERSION}" +echo "Android Platform: ${ANDROID_PLATFORM}" + +wget -q https://dl.google.com/android/repository/commandlinetools-linux-${COMMANDLINETOOLS_VERSION}_latest.zip -O commandlinetools-linux.zip +echo "${COMMANDLINETOOLS_SHA256} commandlinetools-linux.zip" | sha256sum --check - +unzip commandlinetools-linux.zip +rm commandlinetools-linux.zip +mv cmdline-tools/ "${ASDKTOOLS_HOME}/" +# The following popular fix makes sdkmanager honour $http_proxy variables +mv ${ASDKTOOLS_HOME}/bin/sdkmanager ${ASDKTOOLS_HOME}/bin/sdkmanager-vanilla +cat >${ASDKTOOLS_HOME}/bin/sdkmanager <<"EOF" +#!/bin/sh +if test -n "$http_proxy"; then + PROXY_HOST=`echo $http_proxy | sed 's@.*//\(.*\):.*@\1@'` + PROXY_PORT=`echo $http_proxy | sed 's@.*//.*:\(.*\)@\1@'` + PROXY="--proxy=http --proxy_host=$PROXY_HOST --proxy_port=$PROXY_PORT" +else + PROXY="" +fi +exec "`dirname $0`/sdkmanager-vanilla" $PROXY "$@" +EOF +for f in ${ASDKTOOLS_HOME}/bin/* ; do + chmod +x "$f" + ln --symbolic "$f" "/usr/bin/`basename $f`" +done + + +cat >/install/package-list-minimal.txt <<EOF +build-tools;26.0.3 +build-tools;${BUILD_TOOLS_VERSION} +cmake;${CMAKE_VERSION} +emulator +extras;android;m2repository +extras;google;auto +extras;google;google_play_services +extras;google;instantapps +extras;google;m2repository +extras;google;market_apk_expansion +extras;google;market_licensing +extras;google;simulators +extras;google;webdriver +platforms;android-26 +platforms;android-${ANDROID_PLATFORM} +tools +ndk;${ANDROID_NDK_VERSION} +EOF + +mkdir /root/.android 2>/dev/null || true +touch /root/.android/repositories.cfg +# NOTE: sdkmanager returns exit code 141 +(yes || true) | sdkmanager --licenses --sdk_root="$ANDROID_HOME" || true +sdkmanager --verbose --package_file=/install/package-list-minimal.txt --sdk_root="$ANDROID_HOME" +test -d "${ANDROID_HOME}/build-tools/${BUILD_TOOLS_VERSION}" +test -d "${ANDROID_HOME}/ndk/${ANDROID_NDK_VERSION}" +for f in ${ANDROID_HOME}/ndk/${ANDROID_NDK_VERSION}/* ; do + ln --symbolic "$f" "/usr/bin/`basename $f`" +done +echo "export ANDROID_HOME=${ANDROID_HOME}" >> /etc/profile +echo "export ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/${ANDROID_NDK_VERSION}/" >> /etc/profile +echo "export ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION}" >> /etc/profile +echo "export ANDROID_NDK_MAJOR=${ANDROID_NDK_MAJOR}" >> /etc/profile Review Comment:   The script appends unsanitized command line arguments directly to `/etc/profile`. If malicious arguments are passed during the Docker build process, they can inject arbitrary commands into the system profile, leading to persistent command execution whenever a user logs in or a shell is started. ########## docker/Dockerfile.ci_adreno: ########## @@ -0,0 +1,46 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# CI docker for Adreno GPU +FROM ci-gpu + +COPY utils/apt-install-and-clear.sh /usr/local/bin/apt-install-and-clear + +RUN apt-get update --fix-missing + +RUN apt-get update && apt-install-and-clear -y clang-format-15 adb + +COPY install/ubuntu_install_androidsdk.sh /install/ubuntu_install_androidsdk.sh +RUN bash /install/ubuntu_install_androidsdk.sh + +ENV ANDROID_HOME=/opt/android-sdk-linux/ + +# Lint +COPY --from=ghcr.io/astral-sh/uv:0.10.5 /uv /uvx /bin/ + +COPY utils/apt-install-and-clear.sh /usr/local/bin/apt-install-and-clear +COPY utils/download-and-verify.sh /usr/local/bin/download-and-verify + +RUN apt-get update && \ + apt-install-and-clear -y wget git sudo make parallel doxygen graphviz curl shellcheck ca-certificates curl gnupg Review Comment:  The package `curl` is listed twice in this command. ``` apt-install-and-clear -y wget git sudo make parallel doxygen graphviz curl shellcheck ca-certificates gnupg ``` ########## docker/Dockerfile.ci_adreno: ########## @@ -0,0 +1,46 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# CI docker for Adreno GPU +FROM ci-gpu + +COPY utils/apt-install-and-clear.sh /usr/local/bin/apt-install-and-clear + +RUN apt-get update --fix-missing + +RUN apt-get update && apt-install-and-clear -y clang-format-15 adb + +COPY install/ubuntu_install_androidsdk.sh /install/ubuntu_install_androidsdk.sh +RUN bash /install/ubuntu_install_androidsdk.sh + +ENV ANDROID_HOME=/opt/android-sdk-linux/ + +# Lint +COPY --from=ghcr.io/astral-sh/uv:0.10.5 /uv /uvx /bin/ + +COPY utils/apt-install-and-clear.sh /usr/local/bin/apt-install-and-clear Review Comment:  This `COPY` command is redundant as `utils/apt-install-and-clear.sh` is already copied on line 21. You can remove this line. ########## docker/install/ubuntu_install_androidsdk.sh: ########## @@ -0,0 +1,114 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +. /etc/profile + +set -o errexit -o nounset +set -o pipefail + +ANDROID_HOME=/opt/android-sdk-linux +ASDKTOOLS_HOME=/opt/android-sdk-tools +ASDKTOOLS_VERSION=3859397 +ASDKTOOLS_SHA256=444e22ce8ca0f67353bda4b85175ed3731cae3ffa695ca18119cbacef1c1bea0 +COMMANDLINETOOLS_VERSION=11076708 +COMMANDLINETOOLS_SHA256=2d2d50857e4eb553af5a6dc3ad507a17adf43d115264b1afc116f95c92e5e258 + +ANDROID_NDK_VERSION=26.3.11579264 +CMAKE_VERSION=3.6.4111459 +BUILD_TOOLS_VERSION=34.0.0 +ANDROID_PLATFORM=27 +ANDROID_NDK_MAJOR=26 + +if [ $# -gt 0 ] ; then + ANDROID_NDK_VERSION=$1 + ANDROID_NDK_MAJOR=`echo $1 | cut -d "." -f1` +fi +if [ $# -gt 1 ] ; then + CMAKE_VERSION=$2 +fi +if [ $# -gt 2 ] ; then + BUILD_TOOLS_VERSION=$3 +fi +if [ $# -gt 3 ] ; then + ANDROID_PLATFORM=$4 +fi + +echo "NDK Version: ${ANDROID_NDK_VERSION}" +echo "NDK Major : ${ANDROID_NDK_MAJOR}" +echo "Cmake Version: ${CMAKE_VERSION}" +echo "Build Tools: ${BUILD_TOOLS_VERSION}" +echo "Android Platform: ${ANDROID_PLATFORM}" + +wget -q https://dl.google.com/android/repository/commandlinetools-linux-${COMMANDLINETOOLS_VERSION}_latest.zip -O commandlinetools-linux.zip +echo "${COMMANDLINETOOLS_SHA256} commandlinetools-linux.zip" | sha256sum --check - +unzip commandlinetools-linux.zip +rm commandlinetools-linux.zip +mv cmdline-tools/ "${ASDKTOOLS_HOME}/" +# The following popular fix makes sdkmanager honour $http_proxy variables +mv ${ASDKTOOLS_HOME}/bin/sdkmanager ${ASDKTOOLS_HOME}/bin/sdkmanager-vanilla +cat >${ASDKTOOLS_HOME}/bin/sdkmanager <<"EOF" +#!/bin/sh +if test -n "$http_proxy"; then + PROXY_HOST=`echo $http_proxy | sed 's@.*//\(.*\):.*@\1@'` + PROXY_PORT=`echo $http_proxy | sed 's@.*//.*:\(.*\)@\1@'` Review Comment:   The generated `sdkmanager` script is vulnerable to command injection via the `http_proxy` environment variable. The script uses `echo $http_proxy` without quotes inside backticks, which allows for shell expansion and arbitrary command execution if the variable contains malicious characters. ```suggestion PROXY_HOST=`echo "$http_proxy" | sed 's@.*//\(.*\):.*@\1@'` PROXY_PORT=`echo "$http_proxy" | sed 's@.*//.*:\(.*\)@\1@'` ``` ########## tests/python/relax/backend/adreno/test_clml_ops.py: ########## @@ -492,15 +530,133 @@ def test_global_max_pool(dtype, trials): low, high = -1, 1 (input_shape, keep_dims) = trials N, C, H, W = input_shape - pool_size = (H, W) - stride = (1, 1) - padding = (0, 0, 0, 0) + pool_size, stride, padding = (H, W), (1, 1), (0, 0, 0, 0) mod = get_relax_global_maxpool_mod(input_shape, keep_dims, dtype) - params_np = {} - exp_codegen_str = get_global_maxpool_expected_codegen( + clml_codegen = get_global_maxpool_expected_codegen( input_shape, pool_size, stride, padding, "global_max", dtype ) - verify(mod, params_np, exp_codegen_str) + + inputs_np = [np.random.uniform(low, high, size=input_shape).astype(dtype)] + verify(mod, clml_codegen, inputs_np, {}) + + [email protected]( + CLML_VERSION < 5, + reason="Requires target device with CLML v5 or above", +) [email protected]( + "K, N, M", + [ + (4096, 11008, 256), + (2048, 32768, 128), + (4096, 4096, 512), + (4096, 22016, 64), + (16384, 2048, 128), + (2048, 2560, 1024), + (3072, 9216, 256), + (14336, 4096, 128), + (1536, 17920, 128), + (8960, 1536, 1024), + ], +) +def test_dequant_matmul(K, N, M): + x_data = np.random.uniform(-0.1, 0.1, size=(1, M, K)).astype("float16") + weight = np.random.randint(0, 100, size=(K // 8, N)).astype("uint32") + scale = np.random.uniform(-0.1, 0.1, size=(K // 32, N)).astype("float16") + + mod = get_dequant_matmul_module(K, N) + clml_codegen = [ + { + "op": "input", + "name": "", + "attrs": {"shape": [[[K // 8, N]]], "dtype": [["uint32"]]}, + }, + { + "op": "input", + "name": "", + "attrs": {"shape": [[[K // 32, N]]], "dtype": [["float16"]]}, + }, + { + "op": "input", + "name": "", + "attrs": {"shape": [[[1, -1, K]]], "dtype": [["float16"]]}, + }, + { + "op": "kernel", + "name": "", + "inputs": [[0, 0, 0], [1, 0, 0], [2, 0, 0]], + "attrs": { + "dtype": [["float16"]], + "num_inputs": "3", + "num_outputs": "1", + "out_dtype": [["float16"]], + "shape": [[[1, -1, N]]], Review Comment:  The format of attributes in this expected codegen seems to be using an older, more nested format (e.g., `[["float16"]]`) and string values for numbers. This is inconsistent with the simplifications made in other test helpers in `mod_utils.py` and other tests in this file. Please update it to the new format. ```suggestion "dtype": ["float16"], "num_inputs": 3, "num_outputs": 1, "out_dtype": ["float16"], "shape": [[1, -1, N]], ``` ########## docker/Dockerfile.ci_adreno: ########## @@ -0,0 +1,46 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# CI docker for Adreno GPU +FROM ci-gpu + +COPY utils/apt-install-and-clear.sh /usr/local/bin/apt-install-and-clear + +RUN apt-get update --fix-missing Review Comment:  There are multiple `apt-get update` calls in this Dockerfile (lines 23, 25, 38). It's a good practice to chain `apt-get update` with `apt-get install` (or `apt-install-and-clear` in this case) in a single `RUN` statement to avoid caching issues and reduce the number of layers. Consider consolidating all package installations into a single `RUN` block. ########## docker/install/ubuntu_install_androidsdk.sh: ########## @@ -0,0 +1,114 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +. /etc/profile + +set -o errexit -o nounset +set -o pipefail + +ANDROID_HOME=/opt/android-sdk-linux +ASDKTOOLS_HOME=/opt/android-sdk-tools +ASDKTOOLS_VERSION=3859397 +ASDKTOOLS_SHA256=444e22ce8ca0f67353bda4b85175ed3731cae3ffa695ca18119cbacef1c1bea0 +COMMANDLINETOOLS_VERSION=11076708 +COMMANDLINETOOLS_SHA256=2d2d50857e4eb553af5a6dc3ad507a17adf43d115264b1afc116f95c92e5e258 + +ANDROID_NDK_VERSION=26.3.11579264 +CMAKE_VERSION=3.6.4111459 +BUILD_TOOLS_VERSION=34.0.0 +ANDROID_PLATFORM=27 +ANDROID_NDK_MAJOR=26 + +if [ $# -gt 0 ] ; then + ANDROID_NDK_VERSION=$1 + ANDROID_NDK_MAJOR=`echo $1 | cut -d "." -f1` +fi +if [ $# -gt 1 ] ; then + CMAKE_VERSION=$2 +fi +if [ $# -gt 2 ] ; then + BUILD_TOOLS_VERSION=$3 +fi +if [ $# -gt 3 ] ; then + ANDROID_PLATFORM=$4 +fi + +echo "NDK Version: ${ANDROID_NDK_VERSION}" +echo "NDK Major : ${ANDROID_NDK_MAJOR}" +echo "Cmake Version: ${CMAKE_VERSION}" +echo "Build Tools: ${BUILD_TOOLS_VERSION}" +echo "Android Platform: ${ANDROID_PLATFORM}" + +wget -q https://dl.google.com/android/repository/commandlinetools-linux-${COMMANDLINETOOLS_VERSION}_latest.zip -O commandlinetools-linux.zip +echo "${COMMANDLINETOOLS_SHA256} commandlinetools-linux.zip" | sha256sum --check - +unzip commandlinetools-linux.zip +rm commandlinetools-linux.zip +mv cmdline-tools/ "${ASDKTOOLS_HOME}/" +# The following popular fix makes sdkmanager honour $http_proxy variables +mv ${ASDKTOOLS_HOME}/bin/sdkmanager ${ASDKTOOLS_HOME}/bin/sdkmanager-vanilla +cat >${ASDKTOOLS_HOME}/bin/sdkmanager <<"EOF" +#!/bin/sh +if test -n "$http_proxy"; then + PROXY_HOST=`echo $http_proxy | sed 's@.*//\(.*\):.*@\1@'` + PROXY_PORT=`echo $http_proxy | sed 's@.*//.*:\(.*\)@\1@'` + PROXY="--proxy=http --proxy_host=$PROXY_HOST --proxy_port=$PROXY_PORT" +else + PROXY="" +fi +exec "`dirname $0`/sdkmanager-vanilla" $PROXY "$@" +EOF +for f in ${ASDKTOOLS_HOME}/bin/* ; do + chmod +x "$f" + ln --symbolic "$f" "/usr/bin/`basename $f`" +done + + +cat >/install/package-list-minimal.txt <<EOF +build-tools;26.0.3 +build-tools;${BUILD_TOOLS_VERSION} +cmake;${CMAKE_VERSION} +emulator +extras;android;m2repository +extras;google;auto +extras;google;google_play_services +extras;google;instantapps +extras;google;m2repository +extras;google;market_apk_expansion +extras;google;market_licensing +extras;google;simulators +extras;google;webdriver +platforms;android-26 +platforms;android-${ANDROID_PLATFORM} +tools +ndk;${ANDROID_NDK_VERSION} +EOF + +mkdir /root/.android 2>/dev/null || true Review Comment:  Instead of redirecting stderr to `/dev/null` and using `|| true`, you can use `mkdir -p` which is idempotent and won't fail if the directory already exists. ```suggestion mkdir -p /root/.android ``` ########## tests/python/relax/backend/adreno/test_clml_ops.py: ########## @@ -492,15 +530,133 @@ def test_global_max_pool(dtype, trials): low, high = -1, 1 (input_shape, keep_dims) = trials N, C, H, W = input_shape - pool_size = (H, W) - stride = (1, 1) - padding = (0, 0, 0, 0) + pool_size, stride, padding = (H, W), (1, 1), (0, 0, 0, 0) mod = get_relax_global_maxpool_mod(input_shape, keep_dims, dtype) - params_np = {} - exp_codegen_str = get_global_maxpool_expected_codegen( + clml_codegen = get_global_maxpool_expected_codegen( input_shape, pool_size, stride, padding, "global_max", dtype ) - verify(mod, params_np, exp_codegen_str) + + inputs_np = [np.random.uniform(low, high, size=input_shape).astype(dtype)] + verify(mod, clml_codegen, inputs_np, {}) + + [email protected]( + CLML_VERSION < 5, + reason="Requires target device with CLML v5 or above", +) [email protected]( + "K, N, M", + [ + (4096, 11008, 256), + (2048, 32768, 128), + (4096, 4096, 512), + (4096, 22016, 64), + (16384, 2048, 128), + (2048, 2560, 1024), + (3072, 9216, 256), + (14336, 4096, 128), + (1536, 17920, 128), + (8960, 1536, 1024), + ], +) +def test_dequant_matmul(K, N, M): + x_data = np.random.uniform(-0.1, 0.1, size=(1, M, K)).astype("float16") + weight = np.random.randint(0, 100, size=(K // 8, N)).astype("uint32") + scale = np.random.uniform(-0.1, 0.1, size=(K // 32, N)).astype("float16") + + mod = get_dequant_matmul_module(K, N) + clml_codegen = [ + { + "op": "input", + "name": "", + "attrs": {"shape": [[[K // 8, N]]], "dtype": [["uint32"]]}, + }, + { + "op": "input", + "name": "", + "attrs": {"shape": [[[K // 32, N]]], "dtype": [["float16"]]}, + }, + { + "op": "input", + "name": "", + "attrs": {"shape": [[[1, -1, K]]], "dtype": [["float16"]]}, + }, + { + "op": "kernel", + "name": "", + "inputs": [[0, 0, 0], [1, 0, 0], [2, 0, 0]], + "attrs": { + "dtype": [["float16"]], + "num_inputs": "3", + "num_outputs": "1", + "out_dtype": [["float16"]], + "shape": [[[1, -1, N]]], + }, + }, + ] + + inputs_np = [x_data, weight, scale] + verify(mod, clml_codegen, inputs_np, {}, target_minimum_clml_version=5) + + [email protected]( + CLML_VERSION < 5, + reason="Requires compiler supporting CLML v5 or above", +) [email protected]( + "K, N", + [ + (4096, 11008), + (2048, 32768), + (4096, 4096), + (4096, 22016), + (16384, 2048), + (2048, 2560), + (3072, 9216), + (4096, 28672), + (14336, 4096), + (1536, 17920), + (8960, 1536), + ], +) +def test_dequant_vec_matmul(K, N): + x_data = np.random.uniform(-0.1, 0.1, size=(1, 1, K)).astype("float16") + weight = np.random.randint(0, 100, size=(K // 8, N)).astype("uint32") + scale = np.random.uniform(-0.1, 0.1, size=(K // 32, N)).astype("float16") + + mod = get_dequant_vec_matmul_module(K, N) + clml_codegen = [ + { + "op": "input", + "name": "", + "attrs": {"shape": [[[K // 8, -1]]], "dtype": [["uint32"]]}, + }, + { + "op": "input", + "name": "", + "attrs": {"shape": [[[K // 32, -1]]], "dtype": [["float16"]]}, + }, + { + "op": "input", + "name": "", + "attrs": {"shape": [[[1, 1, K]]], "dtype": [["float16"]]}, + }, + { + "op": "kernel", + "name": "", + "inputs": [[0, 0, 0], [1, 0, 0], [2, 0, 0]], + "attrs": { + "dtype": [["float16"]], + "num_inputs": "3", + "num_outputs": "1", + "out_dtype": [["float16"]], + "shape": [[[1, 1, -1]]], + }, Review Comment:  Similar to `test_dequant_matmul`, the attributes format here seems outdated. It should be updated to the simplified format used in other tests. ```suggestion "dtype": ["float16"], "num_inputs": 3, "num_outputs": 1, "out_dtype": ["float16"], "shape": [[1, 1, -1]], ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
