|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 22, |
| 6 | + "id": "de760097-9dce-4894-9a07-805082c43aac", |
| 7 | + "metadata": { |
| 8 | + "tags": [] |
| 9 | + }, |
| 10 | + "outputs": [ |
| 11 | + { |
| 12 | + "name": "stdout", |
| 13 | + "output_type": "stream", |
| 14 | + "text": [ |
| 15 | + "mindspore output -> [1.2 1.1]\n", |
| 16 | + "torch output -> tensor([1.2000, 1.1000], dtype=torch.float64)\n", |
| 17 | + "mlx output -> array([1.2, 1.1], dtype=float32)\n", |
| 18 | + "jax output -> [1.2 1.1]\n" |
| 19 | + ] |
| 20 | + } |
| 21 | + ], |
| 22 | + "source": [ |
| 23 | + "import numpy as np\n", |
| 24 | + "import mindspore as ms\n", |
| 25 | + "import torch\n", |
| 26 | + "import mlx.core as mlx\n", |
| 27 | + "import jax.numpy as jnp\n", |
| 28 | + "x = np.array([-1.2,1.1])\n", |
| 29 | + "\n", |
| 30 | + "y1 = ms.ops.abs(ms.tensor(x))\n", |
| 31 | + "y2 = torch.abs(torch.tensor(x))\n", |
| 32 | + "y3 = mlx.abs(x)\n", |
| 33 | + "y4 = jnp.abs(x)\n", |
| 34 | + "print ('mindspore output -> ',y1)\n", |
| 35 | + "print ('torch output -> ',y2)\n", |
| 36 | + "print ('mlx output -> ',y3)\n", |
| 37 | + "print ('jax output -> ',y4)" |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + "cell_type": "code", |
| 42 | + "execution_count": 27, |
| 43 | + "id": "e6227cd2-c003-471a-bb8c-3ef79bf84b8a", |
| 44 | + "metadata": { |
| 45 | + "tags": [] |
| 46 | + }, |
| 47 | + "outputs": [ |
| 48 | + { |
| 49 | + "name": "stdout", |
| 50 | + "output_type": "stream", |
| 51 | + "text": [ |
| 52 | + "mindspore output -> [1.62788206+0.j]\n", |
| 53 | + "torch output -> tensor([1.6279], dtype=torch.float64)\n", |
| 54 | + "mlx output -> array([1.62788], dtype=float32)\n", |
| 55 | + "jax output -> [1.6278821]\n" |
| 56 | + ] |
| 57 | + } |
| 58 | + ], |
| 59 | + "source": [ |
| 60 | + "\n", |
| 61 | + "x1 = np.array([-1.2+1.1j])\n", |
| 62 | + "\n", |
| 63 | + "y1 = ms.ops.abs(ms.tensor(x1))\n", |
| 64 | + "y2 = torch.abs(torch.tensor(x1))\n", |
| 65 | + "y3 = mlx.abs(x1)\n", |
| 66 | + "y4 = jnp.abs(x1)\n", |
| 67 | + "print ('mindspore output -> ',y1)\n", |
| 68 | + "print ('torch output -> ',y2)\n", |
| 69 | + "print ('mlx output -> ',y3)\n", |
| 70 | + "print ('jax output -> ',y4)" |
| 71 | + ] |
| 72 | + }, |
| 73 | + { |
| 74 | + "cell_type": "markdown", |
| 75 | + "id": "4e3f92f8-a15b-47be-9a72-d54d1cd53a9b", |
| 76 | + "metadata": {}, |
| 77 | + "source": [ |
| 78 | + "1、增加显示dtype\n", |
| 79 | + "2、报错信息建议优化,后续更新" |
| 80 | + ] |
| 81 | + }, |
| 82 | + { |
| 83 | + "cell_type": "code", |
| 84 | + "execution_count": null, |
| 85 | + "id": "f8d512f0-b8e1-4f06-bd26-c904bed63ae0", |
| 86 | + "metadata": {}, |
| 87 | + "outputs": [], |
| 88 | + "source": [] |
| 89 | + }, |
| 90 | + { |
| 91 | + "cell_type": "code", |
| 92 | + "execution_count": null, |
| 93 | + "id": "eeb558d6-4a48-495b-9f8a-a78ddc8a0ed3", |
| 94 | + "metadata": {}, |
| 95 | + "outputs": [], |
| 96 | + "source": [] |
| 97 | + }, |
| 98 | + { |
| 99 | + "cell_type": "code", |
| 100 | + "execution_count": null, |
| 101 | + "id": "eff1b7bc-97a3-44cd-923b-980a3ba44297", |
| 102 | + "metadata": {}, |
| 103 | + "outputs": [], |
| 104 | + "source": [] |
| 105 | + }, |
| 106 | + { |
| 107 | + "cell_type": "code", |
| 108 | + "execution_count": null, |
| 109 | + "id": "3c985809-60dc-42e2-bb6d-58564eda94e2", |
| 110 | + "metadata": {}, |
| 111 | + "outputs": [], |
| 112 | + "source": [] |
| 113 | + }, |
| 114 | + { |
| 115 | + "cell_type": "code", |
| 116 | + "execution_count": null, |
| 117 | + "id": "e0e4664f-af81-4d84-b5d4-6e92a79a51a0", |
| 118 | + "metadata": {}, |
| 119 | + "outputs": [], |
| 120 | + "source": [] |
| 121 | + }, |
| 122 | + { |
| 123 | + "cell_type": "code", |
| 124 | + "execution_count": null, |
| 125 | + "id": "3d50854a-21e0-4ab1-9044-9949ec01dcfd", |
| 126 | + "metadata": {}, |
| 127 | + "outputs": [], |
| 128 | + "source": [] |
| 129 | + }, |
| 130 | + { |
| 131 | + "cell_type": "raw", |
| 132 | + "id": "5603cc2f-e433-4fa0-9b9f-58f61b11f841", |
| 133 | + "metadata": {}, |
| 134 | + "source": [] |
| 135 | + }, |
| 136 | + { |
| 137 | + "cell_type": "code", |
| 138 | + "execution_count": null, |
| 139 | + "id": "3dcff971-5056-4d60-a2f0-43fbdc9fec24", |
| 140 | + "metadata": {}, |
| 141 | + "outputs": [], |
| 142 | + "source": [] |
| 143 | + }, |
| 144 | + { |
| 145 | + "cell_type": "code", |
| 146 | + "execution_count": null, |
| 147 | + "id": "635249dd-f9e6-403a-8e95-05fb1c0bf54d", |
| 148 | + "metadata": {}, |
| 149 | + "outputs": [], |
| 150 | + "source": [] |
| 151 | + }, |
| 152 | + { |
| 153 | + "cell_type": "code", |
| 154 | + "execution_count": null, |
| 155 | + "id": "371cbb6d-c07d-4edc-b860-40764a8fed74", |
| 156 | + "metadata": {}, |
| 157 | + "outputs": [], |
| 158 | + "source": [] |
| 159 | + }, |
| 160 | + { |
| 161 | + "cell_type": "code", |
| 162 | + "execution_count": null, |
| 163 | + "id": "19ab271e-fe71-4a9a-8a53-6c1e57b8b226", |
| 164 | + "metadata": {}, |
| 165 | + "outputs": [], |
| 166 | + "source": [] |
| 167 | + }, |
| 168 | + { |
| 169 | + "cell_type": "code", |
| 170 | + "execution_count": null, |
| 171 | + "id": "d2cb08b7-b2f3-49e3-bfda-6dcc5ec924a4", |
| 172 | + "metadata": {}, |
| 173 | + "outputs": [], |
| 174 | + "source": [] |
| 175 | + }, |
| 176 | + { |
| 177 | + "cell_type": "code", |
| 178 | + "execution_count": null, |
| 179 | + "id": "af68bfbd-2de5-4942-969d-f53c21809092", |
| 180 | + "metadata": {}, |
| 181 | + "outputs": [], |
| 182 | + "source": [] |
| 183 | + } |
| 184 | + ], |
| 185 | + "metadata": { |
| 186 | + "kernelspec": { |
| 187 | + "display_name": "Python 3 (ipykernel)", |
| 188 | + "language": "python", |
| 189 | + "name": "python3" |
| 190 | + }, |
| 191 | + "language_info": { |
| 192 | + "codemirror_mode": { |
| 193 | + "name": "ipython", |
| 194 | + "version": 3 |
| 195 | + }, |
| 196 | + "file_extension": ".py", |
| 197 | + "mimetype": "text/x-python", |
| 198 | + "name": "python", |
| 199 | + "nbconvert_exporter": "python", |
| 200 | + "pygments_lexer": "ipython3", |
| 201 | + "version": "3.10.9" |
| 202 | + } |
| 203 | + }, |
| 204 | + "nbformat": 4, |
| 205 | + "nbformat_minor": 5 |
| 206 | +} |
0 commit comments