Merged
fix(tests): Delete unused simulator add test case #5957
chaizhengtongAdd on Sep 5
fix(tests): Delete unused simulator add test case #5957
Merged
Merged fromchai-hw/pypto_chaidelete_utintocann/pyptomaster
Total: 1 files changed+0-65
| @@ -1,65 +0,0 @@ | |||
| 1 | -#!/usr/bin/env python3 | ||
| 2 | -# coding: utf-8 | ||
| 3 | -# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | -# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 5 | -# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | -# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 8 | -# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 9 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 10 | -# ----------------------------------------------------------------------------------------------------------- | ||
| 11 | -""" | ||
| 12 | -This test case verifies that the swimlane diagram generation for the costmodel works correctly | ||
| 13 | -regardless of whether the CANN is installed in the environment or not. | ||
| 14 | -""" | ||
| 15 | - | ||
| 16 | -import numpy as np | ||
| 17 | -from numpy.testing import assert_allclose | ||
| 18 | -import torch | ||
| 19 | - | ||
| 20 | -import pypto | ||
| 21 | - | ||
| 22 | - | ||
| 23 | -@pypto.frontend.jit( | ||
| 24 | - runtime_options={"run_mode": 1} | ||
| 25 | -) | ||
| 26 | -def add_kernel( | ||
| 27 | - x: pypto.Tensor([...], pypto.DT_FP32), | ||
| 28 | - y: pypto.Tensor([...], pypto.DT_FP32), | ||
| 29 | - out: pypto.Tensor([...], pypto.DT_FP32), | ||
| 30 | -): | ||
| 31 | - """ | ||
| 32 | - Add implementation. | ||
| 33 | - | ||
| 34 | - Parameters | ||
| 35 | - ---------- | ||
| 36 | - x : pypto.Tensor | ||
| 37 | - First input tensor | ||
| 38 | - y : pypto.Tensor | ||
| 39 | - Second input tensor | ||
| 40 | - out : pypto.Tensor | ||
| 41 | - Output tensor | ||
| 42 | - """ | ||
| 43 | - pypto.set_vec_tile_shapes(1, 4, 1, 64) | ||
| 44 | - out[:] = x + y | ||
| 45 | - | ||
| 46 | - | ||
| 47 | -def test_add(): | ||
| 48 | - """ | ||
| 49 | - Test add implementation against PyTorch reference. | ||
| 50 | - """ | ||
| 51 | - shape = (1, 4, 1, 64) | ||
| 52 | - | ||
| 53 | - # Prepare data | ||
| 54 | - input_data0 = torch.rand(shape, dtype=torch.float32) | ||
| 55 | - input_data1 = torch.rand(shape, dtype=torch.float32) | ||
| 56 | - output_data = torch.empty(shape, dtype=torch.float32) | ||
| 57 | - | ||
| 58 | - add_kernel(input_data0, input_data1, output_data) | ||
| 59 | - | ||
| 60 | - golden = torch.add(input_data0, input_data1) | ||
| 61 | - assert_allclose(np.array(output_data.cpu()), np.array(golden.cpu()), rtol=3e-3, atol=3e-3) | ||
| 62 | - | ||
| 63 | - | ||
| 64 | -if __name__ == "__main__": | ||
| 65 | - test_add() | ||