Api
Modules:
| Name | Description |
|---|---|
array |
|
buffer |
|
buffer_cuda |
|
dtypes |
|
kernels |
|
transpiler |
|
utils |
|
Classes:
| Name | Description |
|---|---|
Array |
|
Buffer |
|
BufferCuda |
|
PythonModule |
|
Functions:
| Name | Description |
|---|---|
compile_str |
Transpile a python function into a C source code string. |
ref |
Equal to doing &x in C. Returning [x] is just for type hinting purposes. |
Attributes:
| Name | Type | Description |
|---|---|---|
element_wise_module |
|
element_wise_module = element_wise_module.compile()
module-attribute
Array
Methods:
| Name | Description |
|---|---|
__getitem__ |
|
__init__ |
|
__repr__ |
|
arange |
|
binary_op |
|
from_iterable |
|
reduction_op |
|
reshape |
|
squeeze |
|
to_python |
|
transpose |
|
unary_op |
|
Attributes:
| Name | Type | Description |
|---|---|---|
T |
'Array'
|
|
__add__ |
|
|
__div__ |
|
|
__mul__ |
|
|
__sub__ |
|
|
__truediv__ |
|
|
acos |
|
|
asin |
|
|
atan |
|
|
atan2 |
|
|
cos |
|
|
cosh |
|
|
data |
|
|
device |
Device
|
|
exp |
|
|
exp2 |
|
|
is_contiguous |
|
|
log |
|
|
log10 |
|
|
log2 |
|
|
mT |
'Array'
|
|
max |
|
|
min |
|
|
ndim |
|
|
offset |
|
|
prod |
|
|
relu |
|
|
shape |
|
|
sin |
|
|
sinh |
|
|
size |
int
|
|
sqrt |
|
|
square |
|
|
strides |
|
|
sum |
|
|
tan |
|
|
tanh |
|
Source code in src/simplendarray/array.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
T: 'Array'
property
__add__ = binary_op('add')
class-attribute
instance-attribute
__div__ = binary_op('div')
class-attribute
instance-attribute
__mul__ = binary_op('mul')
class-attribute
instance-attribute
__sub__ = binary_op('sub')
class-attribute
instance-attribute
__truediv__ = binary_op('div')
class-attribute
instance-attribute
acos = unary_op('acos')
class-attribute
instance-attribute
asin = unary_op('asin')
class-attribute
instance-attribute
atan = unary_op('atan')
class-attribute
instance-attribute
atan2 = binary_op('atan2')
class-attribute
instance-attribute
cos = unary_op('cos')
class-attribute
instance-attribute
cosh = unary_op('cosh')
class-attribute
instance-attribute
data = buffer
instance-attribute
device: Device
property
exp = unary_op('exp')
class-attribute
instance-attribute
exp2 = unary_op('exp2')
class-attribute
instance-attribute
is_contiguous
property
log = unary_op('log')
class-attribute
instance-attribute
log10 = unary_op('log10')
class-attribute
instance-attribute
log2 = unary_op('log2')
class-attribute
instance-attribute
mT: 'Array'
property
max = reduction_op('max')
class-attribute
instance-attribute
min = reduction_op('min')
class-attribute
instance-attribute
ndim
property
offset = offset
instance-attribute
prod = reduction_op('mul')
class-attribute
instance-attribute
relu = unary_op('relu')
class-attribute
instance-attribute
shape = shape
instance-attribute
sin = unary_op('sin')
class-attribute
instance-attribute
sinh = unary_op('sinh')
class-attribute
instance-attribute
size: int
property
sqrt = unary_op('sqrt')
class-attribute
instance-attribute
square = unary_op('square')
class-attribute
instance-attribute
strides = strides
instance-attribute
sum = reduction_op('add')
class-attribute
instance-attribute
tan = unary_op('tan')
class-attribute
instance-attribute
tanh = unary_op('tanh')
class-attribute
instance-attribute
__getitem__(items: tuple[int | slice, ...] | int | slice)
Source code in src/simplendarray/array.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
__init__(buffer: BufferType, shape: tuple[int, ...], strides: tuple[int, ...], offset: int)
Source code in src/simplendarray/array.py
80 81 82 83 84 | |
__repr__() -> str
Source code in src/simplendarray/array.py
106 107 | |
arange(numel: int, dtype: str | type[DType], device: Device = 'cpu') -> 'Array'
classmethod
Source code in src/simplendarray/array.py
71 72 73 74 75 76 77 78 | |
binary_op(op: str)
staticmethod
Source code in src/simplendarray/array.py
247 248 249 250 251 252 253 254 255 | |
from_iterable(data: NestedIterable | Scalar, dtype: str | type[DType], device: Device = 'cpu')
classmethod
Source code in src/simplendarray/array.py
62 63 64 65 66 67 68 69 | |
reduction_op(op: str)
staticmethod
Source code in src/simplendarray/array.py
264 265 266 267 268 269 270 271 272 273 | |
reshape(new_shape: int | tuple[int, ...]) -> 'Array'
Source code in src/simplendarray/array.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
squeeze(dims: int | Iterable[int]) -> 'Array'
Source code in src/simplendarray/array.py
120 121 122 123 124 125 126 127 128 | |
to_python() -> NestedIterable
Source code in src/simplendarray/array.py
109 110 111 112 113 114 115 116 117 118 | |
transpose(dims: Iterable[int]) -> 'Array'
Source code in src/simplendarray/array.py
157 158 159 160 | |
unary_op(op: str)
staticmethod
Source code in src/simplendarray/array.py
218 219 220 221 222 223 224 225 226 | |
Buffer
Methods:
| Name | Description |
|---|---|
__init__ |
|
__repr__ |
|
empty |
|
from_iterable |
|
Attributes:
| Name | Type | Description |
|---|---|---|
data |
|
|
device |
Device
|
|
typecode |
|
Source code in src/simplendarray/buffer.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
data = data
instance-attribute
device: Device = 'cpu'
instance-attribute
typecode = data.typecode
instance-attribute
__init__(data: array.array)
Source code in src/simplendarray/buffer.py
11 12 13 14 15 16 | |
__repr__() -> str
Source code in src/simplendarray/buffer.py
28 29 | |
empty(size: int, dtype: str) -> Buffer
classmethod
Source code in src/simplendarray/buffer.py
18 19 20 21 | |
from_iterable(data: Iterable[int | float | bool], dtype: str) -> Buffer
classmethod
Source code in src/simplendarray/buffer.py
23 24 25 26 | |
BufferCuda
Methods:
| Name | Description |
|---|---|
__del__ |
|
__init__ |
|
__repr__ |
|
copy_from_host |
Copy data from a CPU buffer or array.array to this GPU buffer. |
copy_to_host |
Copy data from this GPU buffer to a new CPU array.array. |
empty |
|
from_iterable |
|
Attributes:
| Name | Type | Description |
|---|---|---|
address |
|
|
data |
array
|
Return a CPU copy of the GPU data for compatibility. |
device |
Device
|
|
dtype |
|
|
num_bytes |
|
|
size |
|
|
typecode |
|
Source code in src/simplendarray/buffer_cuda.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
_owns_memory = True
instance-attribute
address = ptr
instance-attribute
data: array.array
property
Return a CPU copy of the GPU data for compatibility.
device: Device = 'gpu'
instance-attribute
dtype = dtype
instance-attribute
num_bytes = size * array.array(dtype).itemsize
instance-attribute
size = size
instance-attribute
typecode = dtype
instance-attribute
__del__()
Source code in src/simplendarray/buffer_cuda.py
72 73 74 75 76 | |
__init__(size: int, dtype: str)
Source code in src/simplendarray/buffer_cuda.py
23 24 25 26 27 28 29 30 31 32 33 | |
__repr__() -> str
Source code in src/simplendarray/buffer_cuda.py
68 69 70 | |
copy_from_host(cpu_buffer: array.array | HasDataAndAddress) -> None
Copy data from a CPU buffer or array.array to this GPU buffer.
Source code in src/simplendarray/buffer_cuda.py
49 50 51 52 53 54 55 56 57 58 59 60 | |
copy_to_host() -> array.array
Copy data from this GPU buffer to a new CPU array.array.
Source code in src/simplendarray/buffer_cuda.py
62 63 64 65 66 | |
empty(size: int, dtype: str) -> BufferCuda
classmethod
Source code in src/simplendarray/buffer_cuda.py
35 36 37 | |
from_iterable(data: array.array | Iterable[int | float | bool], dtype: str) -> BufferCuda
classmethod
Source code in src/simplendarray/buffer_cuda.py
39 40 41 42 43 44 45 46 47 | |
PythonModule
Methods:
| Name | Description |
|---|---|
__getattr__ |
|
__init__ |
|
compile |
|
compile_fn |
|
Source code in src/simplendarray/transpiler/runtime.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | |
_cache_dir_override: Path | None = None
class-attribute
instance-attribute
_compiled = False
instance-attribute
_funcs: list[CFunction] = []
instance-attribute
_includes = includes or []
instance-attribute
_module = None
instance-attribute
_stub_path = stub_path
instance-attribute
_stub_var = stub_var
instance-attribute
__getattr__(name)
Source code in src/simplendarray/transpiler/runtime.py
511 512 513 514 | |
__init__(includes: list[str] | None = None, stub_path: str | None = None, stub_var: str | None = None)
Source code in src/simplendarray/transpiler/runtime.py
169 170 171 172 173 174 175 | |
_build_dispatch_dicts()
Source code in src/simplendarray/transpiler/runtime.py
501 502 503 504 505 506 507 508 509 | |
_cache_dir() -> Path
staticmethod
Source code in src/simplendarray/transpiler/runtime.py
228 229 230 231 232 233 234 235 236 237 238 | |
_cache_key(ext_src: str, compiler: str, cflags: list[str] | None, ldflags: list[str] | None) -> str
Source code in src/simplendarray/transpiler/runtime.py
251 252 253 254 | |
_cache_lock(cache_dir: Path)
Source code in src/simplendarray/transpiler/runtime.py
240 241 242 243 244 245 246 247 248 249 | |
_generate_extension(module_name)
Source code in src/simplendarray/transpiler/runtime.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
_generate_forward_decl(func: CFunction) -> str
Source code in src/simplendarray/transpiler/runtime.py
328 329 330 331 332 333 334 335 336 | |
_generate_wrapper(func: CFunction)
Source code in src/simplendarray/transpiler/runtime.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | |
_load_from_so(module_name: str, so_path: Path) -> bool
Source code in src/simplendarray/transpiler/runtime.py
256 257 258 259 260 261 262 263 | |
_register(func, c_attrs: list[str], pybind: bool, group: str | None = None)
Source code in src/simplendarray/transpiler/runtime.py
177 178 179 180 181 182 183 184 185 186 187 188 | |
_register_ast(name: str, fn: ast.FunctionDef, c_attrs: list[str], pybind: bool, group: str | None = None, dispatch_key=None)
Source code in src/simplendarray/transpiler/runtime.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
_write_source_stub()
Source code in src/simplendarray/transpiler/runtime.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | |
compile(compiler='gcc', cflags=None, ldflags=None) -> Self
Source code in src/simplendarray/transpiler/runtime.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
compile_fn(types: Iterable[SpecItem] | None = None, c_attrs: list[str] | None = None, pybind: bool = False)
Source code in src/simplendarray/transpiler/runtime.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | |
compile_str(func) -> str
Transpile a python function into a C source code string.
Source code in src/simplendarray/transpiler/transpiler.py
337 338 339 340 341 342 343 344 345 | |
ref(x: T) -> list[T]
Equal to doing &x in C. Returning [x] is just for type hinting purposes.
Source code in src/simplendarray/transpiler/transpiler.py
9 10 11 | |