From 95dc5b89d1bdd41cf50cbfa4a7bb907afe8ab0cf Mon Sep 17 00:00:00 2001 From: lucasdelimanogueira <47654903+lucasdelimanogueira@users.noreply.github.com> Date: Mon, 29 Apr 2024 02:21:38 -0300 Subject: [PATCH] Delete python directory --- python/__pycache__/tensor.cpython-38.pyc | Bin 2369 -> 0 bytes python/__pycache__/tensor.cpython-39.pyc | Bin 2180 -> 0 bytes python/tensor.py | 61 -------------- python/tests.ipynb | 98 ----------------------- 4 files changed, 159 deletions(-) delete mode 100644 python/__pycache__/tensor.cpython-38.pyc delete mode 100644 python/__pycache__/tensor.cpython-39.pyc delete mode 100644 python/tensor.py delete mode 100644 python/tests.ipynb diff --git a/python/__pycache__/tensor.cpython-38.pyc b/python/__pycache__/tensor.cpython-38.pyc deleted file mode 100644 index eedd4bd7e634208b65af7a29ea3f127cbbb0b318..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2369 zcmZ`*OK)366rP#;j2}rF(x-|rRY6#wSS%_k1XV;+AtYoF4J<6s$nlI5o9jpBjuDOQ z4eq*s03q4S@^9GAmR0{k1rpzx>pX#L-7~K<=g#@gch30RYPH1h{PFJl-Jes&{-nXh zC&XYEZ~g&Zy<3iQ8ZI|TM z^pwtBlpnRn+J!^a8#L>wOQjsP2U<#3l5#LolZ^TmDUT=ZY_$@1?6WcUCSQN`MRWhj zH!kVOZZ>LL7jEZ&u4%t3^=s@5DdyF^#9b(EB zY|5AXdoklPVfmC##awV^#RBnO@+p&{75&J@Q$FY0(0zeDGMNg<6tiMZI&07`k=~N8 zdS&YM%ZI^~^}~KeR{i`sS@h!#Y8MsAg!BqaurFTFw^!pOUt+)9R16-8=E?P)oyNhW zm#Ie9J6J)TkLuT4(#_fy6D}GXgwqh_t?=>QmtVR7s-}W5dU|LG0TYoR#+ovTDnzTg z3Tk22rEPQQIpYK75~Fh(y0}=c2QJKY*1cfwj5cNi_K23fVb4lQ-_GwqFc6@`D}0;B zyd>`NO%d~uZ}Q6DCmZ_(Z%+4I3K|`hPV9sB2%STQP$3j^PEzsPY|anGEST~=_QS1N zI1SOR&!VYV@F_yV+4243y9im(6&^^#VWlq2HX0YV$74NI_1N6PuvH$yQ>|py%WZ3o zaFvvQ9Nnr(j>uFRl7zS}QDUd$!JqamgZutbpla zCZ+`lCl8vF!GSilQMcAZG3n^MHkjnLHfY<>S6Qrai#Ct z*+f4vW@J3)3O-TBc~Y4-&}*fK+Debtby^^B%ncGZA?ksL-6g9dxacP`c?DWmmJ(LT zh?MVOTTW~vLZ#v^uZS&>>16ASL}#iU3iRnieFED9eIFgm7D!S6Ne~77P)5`)LP)^N zaWOn)FL|?`T=mVnRqh(CWswfXdq)1e^+i&nVMCNF^xOkX;Xb2GUHhnz>8)XF%?9uWkdnW@-H{{du4^*sOp diff --git a/python/__pycache__/tensor.cpython-39.pyc b/python/__pycache__/tensor.cpython-39.pyc deleted file mode 100644 index 16c079804a3e136ea94de87632d351b1e122fa07..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2180 zcmZuyOOG2x5bo}Iu3y<$n{7 zFt`t2@ihoZhE$Lt6I41IS2|N~OUF#GdgR-Yb76#9{+LbNVIVv_#{>@!WLD(LxFXiE z2@0(eAq(RbNAX-5HxtQh5QQe>Jd0=|BR)>^SQ~G|lT3q=aUxSu@E1f~f(Wd5^=1DkpUHljX8nixXfczS&Wpa1BPC-k z`TRuZYIM{e=XoFcM|sxQ*5y0%6UD%agMeTrLe`=9hX2_4x6ni7`>1>u#5sC`JtKg- zBV1@96T*kq6M+b!^~H{8KpTjrXh9o_HsIDVeg)eIZJs{pNC@8p_=-P3lw?Cnx}`s| z6_WFSMBWoy*g0sRK*ZE4+WVsF}< zI3=07(-v>r`3_pN<4f3XS|9_|t1N+i_8iZy$6LCE{d`vth=>iASMJ>DA1;zq^wZ?9 zhPcS1%O)77v4#ob%@w3kA=buy@bK|te5}>`geKhpyJEvo(oAsN6}-Ow0qE*5J(lIVogyBdV{R#gsq&CJ|sU~U%90VZD-|` zY(q;(2_?t3kM|*E&X`#s6$L91Q&*ueemtMcOhmpyCx^`pB9(%tNuh^3h%3i?XE7TF z#o`bbjGJgVJHH_|WYvZJ@4{DL$OK~BqanN|?#*I7I_l{o*~`uppvFLkk~}M-wuQ~o$26YC=|VnIDp!_s z6`%0NSyHJh&@xL+VNV_6y5uoN?-zedM%; zG*{fkS>awIpOY0mz75RxY_D6=jkCoP;SUV4+24G%We`{ZZCr3uFNa~+3Y{>tD*%rzqdQNuT8#8UNm~l-+W(m|;oa)5dk-ToFykTX GhW`OZM%JSM diff --git a/python/tensor.py b/python/tensor.py deleted file mode 100644 index 7e88fcd..0000000 --- a/python/tensor.py +++ /dev/null @@ -1,61 +0,0 @@ -import ctypes - -class CTensor(ctypes.Structure): - _fields_ = [ - ('data', ctypes.POINTER(ctypes.c_float)), - ('strides', ctypes.POINTER(ctypes.c_int)), - ('shape', ctypes.POINTER(ctypes.c_int)), - ('ndim', ctypes.c_int) - ] - -class Tensor: - def __init__(self, data): - data, shape = self.flatten(data) - print(data, shape) - self.lib = ctypes.CDLL("../build/libtensor.so") # Adjust the path to the shared library - self.data = (ctypes.c_float * len(data))(*data) - self.shape = shape - self.ndim = len(shape) - - self.lib.create_tensor.argtypes = [ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_int), ctypes.c_int] - self.lib.create_tensor.restype = ctypes.POINTER(CTensor) - - self.tensor = self.lib.create_tensor( - self.data, - (ctypes.c_int * len(shape))(*shape), - ctypes.c_int(len(shape)) - ) - - def flatten(self, nested_list): - flat_data = [] - shape = [len(nested_list), len(nested_list[0])] - for sublist in nested_list: - for item in sublist: - flat_data.append(item) - return flat_data, shape - - def __getitem__(self, indices): - if len(indices) != self.ndim: - raise ValueError("Number of indices must match the number of dimensions") - - self.lib.get_item.argtypes = [ctypes.POINTER(CTensor), ctypes.POINTER(ctypes.c_int)] - self.lib.get_item.restype = ctypes.c_float - - indices = (ctypes.c_int * len(indices))(*indices) - value = self.lib.get_item(self.tensor, indices) - - return value - - def shape(self): - return f"Tensor(shape={self.shape})" - - def __str__(self): - result = "" - for i in range(self.shape[0]): - for j in range(self.shape[1]): - result += str(self[i, j]) + " " - result += "\n" - return result.strip() - - def __repr__(self): - return self.__str__() diff --git a/python/tests.ipynb b/python/tests.ipynb deleted file mode 100644 index ca51d7d..0000000 --- a/python/tests.ipynb +++ /dev/null @@ -1,98 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0, 1, 2, 0, 2, 2] [2, 3, 3]\n", - "Tensor shape: [2, 3, 3]\n", - "Tensor created successfully\n", - "Tensor information:\n", - "Number of dimensions: 3\n", - "Shape: [2, 3, 3]\n", - "Data:\n", - "[0.00, 1.00, 2.00, 0.00, 2.00, 2.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00]\n" - ] - } - ], - "source": [ - "from tensor import Tensor\n", - "\n", - "data = [[0, 1, 2], [0, 2, 2], [0, 1, 2]]\n", - "tensor = Tensor(data)\n", - "print(\"Tensor shape:\", tensor.shape)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Tensor created successfully\n", - "Tensor information:\n", - "Number of dimensions: 2\n", - "Shape: [3, 3]\n", - "Data:\n", - "[0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90]\n" - ] - }, - { - "data": { - "text/plain": [ - "0.10000000149011612 0.20000000298023224 0.30000001192092896 \n", - "0.4000000059604645 0.5 0.6000000238418579 \n", - "0.699999988079071 0.800000011920929 0.8999999761581421" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\n", - "data = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]\n", - "shape = [3, 3]\n", - "tensor = Tensor(data, shape)\n", - "tensor\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}