Skip to content

Commit 4c670eb

Browse files
committed
Modified path to pytaco module and various other updates to text
1 parent c769986 commit 4c670eb

File tree

12 files changed

+92
-79
lines changed

12 files changed

+92
-79
lines changed

python_bindings/pytaco/pytensor/taco_tensor.py

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def assemble(self):
300300

301301
def evaluate(self):
302302
"""
303-
Compile, assemble and compute as needed.
303+
Compile, assemble, and compute as needed.
304304
"""
305305
self._tensor.evaluate()
306306

@@ -431,19 +431,20 @@ def copy(self):
431431

432432
def insert(self, coords, val):
433433
"""
434-
Increments the value at a given coordinate (:func:`insert`).
434+
Increments the value at a given set of coordinates.
435435
436436
Parameters
437437
-----------
438438
coords: iter of ints
439-
The coordinate of the tensor we want to assign to val
439+
The coordinates of the tensor element we want to assign to.
440440
441441
val: dtype
442-
The value to assign to the given coordinate
442+
The value to assign the specified element to.
443443
444444
Warnings
445445
----------
446-
This function INCREMENTS the current value at coords.
446+
This function does *not* overwrite the element at the specified
447+
coordinates if it is already non-zero.
447448
448449
Examples
449450
----------
@@ -581,38 +582,38 @@ def from_sp_csc(matrix, copy=True):
581582

582583
def from_array(array, copy=True):
583584

584-
"""Convert a numpy array to a tensor.
585+
"""Convert a NumPy array to a tensor.
585586
586-
Initializes a taco tensor from a numpy array and copies the array by default. This always creates a dense
587+
Initializes a taco tensor from a NumPy array and copies the array by default. This always creates a dense
587588
tensor.
588589
589590
Parameters
590591
------------
591592
array: numpy.array
592-
A numpy array to convert to a taco tensor
593+
A NumPy array to convert to a taco tensor
593594
594595
copy: boolean, optional
595-
If true, taco copies the data from numpy and stores its own copy. If false, taco points to the same
596-
underlying data as the numpy array.
596+
If true, taco copies the data from NumPy and stores its own copy. If false, taco points to the same
597+
underlying data as the NumPy array.
597598
598599
Warnings
599600
---------
600-
Taco's changes to tensors may NOT be visible to numpy since taco places inserts in buffers may copy tensor data
601+
Taco's changes to tensors may NOT be visible to NumPy since taco places inserts in buffers may copy tensor data
601602
after inserting. See notes for details.
602603
603604
Notes
604605
--------
605606
The copy flag is ignored if the input array is not C contiguous or F contiguous (so for most transposed views).
606-
If taco detects an array that is not contiguous, it will always copy the numpy array into a C contiguous format.
607-
Additionally, if the GPU backend is enabled, taco will always copy the numpy array to CUDA unified memory.
607+
If taco detects an array that is not contiguous, it will always copy the NumPy array into a C contiguous format.
608+
Additionally, if the GPU backend is enabled, taco will always copy the NumPy array to CUDA unified memory.
608609
These restriction will be lifted in future versions of taco.
609610
610611
Taco is mainly intended to operate on sparse tensors. As a result, it buffers inserts since inserting into sparse
611612
structures is very costly. This means that when the full tensor structure is needed, taco will copy the tensor to
612613
another location and insert the new values as needed. This saves a lot of time when dealing with sparse structures
613-
but is not needed for dense tensors (like numpy arrays). Currently, taco does this copy for dense and sparse tensors.
614-
As a result, after inserting into a taco tensor numpy will not see the changes since taco will not be writing to
615-
the same memory location that numpy is referencing.
614+
but is not needed for dense tensors (like NumPy arrays). Currently, taco does this copy for dense and sparse tensors.
615+
As a result, after inserting into a taco tensor, NumPy will not see the changes since taco will not be writing to
616+
the same memory location that NumPy is referencing.
616617
617618
618619
See also
@@ -621,7 +622,7 @@ def from_array(array, copy=True):
621622
622623
Examples
623624
----------
624-
If we choose not to copy, modifying the tensor also modifies the numpy array and vice-versa. An example of this is
625+
If we choose not to copy, modifying the tensor also modifies the NumPy array and vice-versa. An example of this is
625626
shown:
626627
627628
.. doctest::
@@ -639,8 +640,8 @@ def from_array(array, copy=True):
639640
Returns
640641
--------
641642
t: tensor
642-
A taco tensor pointing to the same underlying data as the numpy array if copy was set to False. Otherwise,
643-
returns a taco tensor containing data copied from the numpy array.
643+
A taco tensor pointing to the same underlying data as the NumPy array if copy was set to False. Otherwise,
644+
returns a taco tensor containing data copied from the NumPy array.
644645
"""
645646

646647

@@ -657,23 +658,23 @@ def from_array(array, copy=True):
657658

658659
def to_array(t):
659660
"""
660-
Converts a taco tensor to a numpy array.
661+
Converts a taco tensor to a NumPy array.
661662
662663
This always copies the tensor. To avoid the copy for dense tensors, see the notes section.
663664
664665
Parameters
665666
-----------
666667
t: tensor
667-
A taco tensor to convert to a numpy array.
668+
A taco tensor to convert to a NumPy array.
668669
669670
Notes
670671
-------
671-
Dense tensors export python's buffer interface. As a result, they can be converted to numpy arrays using
672+
Dense tensors export python's buffer interface. As a result, they can be converted to NumPy arrays using
672673
``np.array(tensor, copy=False)`` . Attempting to do this for sparse tensors throws an error. Note that as a result
673674
of exporting the buffer interface dense tensors can also be converted to eigen or any other library supporting this
674675
inferface.
675676
676-
Also it is very important to note that if requesting a numpy view of data owned by taco, taco will mark the array as
677+
Also it is very important to note that if requesting a NumPy view of data owned by taco, taco will mark the array as
677678
read only meaning the user cannot write to that data without using the taco reference. This is needed to avoid
678679
raising issues with taco's delayed execution mechanism.
679680
@@ -707,7 +708,7 @@ def to_array(t):
707708
Returns
708709
---------
709710
arr: numpy.array
710-
A numpy array containing a copy of the data in the tensor object t.
711+
A NumPy array containing a copy of the data in the tensor object t.
711712
712713
"""
713714
return np.array(t.to_dense(), copy=True)
@@ -820,7 +821,7 @@ def as_tensor(obj, copy=True):
820821
if isinstance(obj, csr_matrix):
821822
return from_sp_csr(obj, copy)
822823

823-
# Try converting object to numpy array. This will ignore the copy flag
824+
# Try converting object to NumPy array. This will ignore the copy flag
824825
arr = np.array(obj)
825826
return from_array(arr, True)
826827

@@ -2401,7 +2402,7 @@ def matmul(t1, t2, out_format=default_mode, dtype=None):
24012402
24022403
Examples
24032404
---------
2404-
Here we demonstrate broadcasting for a 3-D tensor. We use numpy arrays for demonstration due to easy data
2405+
Here we demonstrate broadcasting for a 3-D tensor. We use NumPy arrays for demonstration due to easy data
24052406
generation. However, we could have given sparse tensors of any format for taco to compute. Note that the
24062407
choice of a tensor format has a big effect on the final performance. For instance it is favorable to multiply
24072408
CSR matrices with CSC since dot products can be easily computed.
@@ -2521,7 +2522,7 @@ def dot(t1, t2, out_format=default_mode, dtype=None):
25212522
"""
25222523
The dot product of two tensors.
25232524
2524-
This implements the same spec as numpy but allows for sparse taco tensors as operands.
2525+
This implements the same spec as NumPy but allows for sparse taco tensors as operands.
25252526
25262527
* If both t1 and t2 are 1-D then this is an inner product.
25272528
@@ -2860,7 +2861,7 @@ def evaluate(expr, *operands, out_format=None, dtype=None):
28602861
the elements of a matrix while the corresponding string would be ``A = B(i, j)``.
28612862
28622863
2863-
The string parser currently only supports +, -, / and *. Thus, expressions involving other functions such as exp,
2864+
The string parser currently only supports +, -, /, and \*. Thus, expressions involving other functions such as exp,
28642865
tan etc, would have to be written using the pythonic expressions.
28652866
28662867
An input tensor is recognised by the parser by a name followed by a comma separated list of index variables in
@@ -2953,7 +2954,7 @@ def einsum(expr, *operands, out_format=None, dtype=None):
29532954
"""
29542955
Evaluates the Einstein summation convention on the input operands.
29552956
2956-
The einsum summation convention employed here is very similar to `numpy's
2957+
The einsum summation convention employed here is very similar to `NumPy's
29572958
<https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html#numpy.einsum>`_ but has some differences
29582959
explained below.
29592960
@@ -2968,7 +2969,7 @@ def einsum(expr, *operands, out_format=None, dtype=None):
29682969
29692970
Warnings
29702971
----------
2971-
This differs from numpy's einsum in two important ways. The first is that the same subscript cannot appear more than
2972+
This differs from NumPy's einsum in two important ways. The first is that the same subscript cannot appear more than
29722973
once in a given operand. The second is that for sparse tensors, some expressions may require the user to explicitly
29732974
transpose the tensors before passing them into einsum.
29742975
@@ -2980,7 +2981,7 @@ def einsum(expr, *operands, out_format=None, dtype=None):
29802981
subscript labels specifying the output.
29812982
29822983
operands: list of array_like, tensors, scipy csr and scipy csc matrices
2983-
This specifies the operands for the computation. Taco will copy any numpy arrays that are not stored in
2984+
This specifies the operands for the computation. Taco will copy any NumPy arrays that are not stored in
29842985
row-major or column-major format.
29852986
29862987
out_format: format, optional
@@ -3060,7 +3061,7 @@ def einsum(expr, *operands, out_format=None, dtype=None):
30603061
>>> pt.tensor_sum(t)[0]
30613062
60.0
30623063
3063-
The `numpy docs <https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html#numpy.einsum>`_ contain
3064+
The `NumPy docs <https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html#numpy.einsum>`_ contain
30643065
more examples and an in depth explanation of this notation can be found
30653066
`here <https://rockt.github.io/2018/04/30/einsum>`_.
30663067
@@ -3083,7 +3084,7 @@ def einsum(expr, *operands, out_format=None, dtype=None):
30833084

30843085
def apply(func_name, arg_list, output_zero_specifier):
30853086
"""
3086-
Applies a user defined function to an :class:`index_expression`.
3087+
Applies a user-defined function to an :class:`index_expression`.
30873088
30883089
Parameters
30893090
------------
@@ -3116,11 +3117,11 @@ def apply(func_name, arg_list, output_zero_specifier):
31163117

31173118
def set_udf_dir(dir_to_search):
31183119
"""
3119-
Sets the directory to search for user defined functions.
3120+
Sets the directory to search for user-defined functions.
31203121
31213122
Parameters
31223123
------------
31233124
dir_to_search: str
3124-
The directory that taco should search when looking for user defined functions.
3125+
The directory that taco should search when looking for user-defined functions.
31253126
"""
31263127
raise NotImplementedError

python_bindings/source/conf.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
#
1313
import os
1414
import sys
15-
sys.path.insert(0, os.path.abspath('..'))
15+
sys.path.insert(0, os.path.abspath('../../build/lib/'))
1616

1717

1818
# -- Project information -----------------------------------------------------
1919

20-
project = 'Taco'
21-
copyright = '2019, MIT COMMIT GROUP'
22-
author = 'MIT COMMIT GROUP'
20+
project = 'TACO Python API Reference'
21+
copyright = '2022 TACO Development Team'
22+
author = 'TACO Development Team'
2323

2424

2525
# -- General configuration ---------------------------------------------------
@@ -58,7 +58,9 @@
5858
# Add any paths that contain custom static files (such as style sheets) here,
5959
# relative to this directory. They are copied after the builtin static files,
6060
# so a file named "default.css" will overwrite the builtin "default.css".
61-
html_static_path = ['_static']
61+
# html_static_path = ['_static']
62+
63+
html_title = 'TACO Python API Reference'
6264

6365

6466
# -- Extension configuration -------------------------------------------------

python_bindings/source/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6-
Welcome to Taco's documentation
6+
Table of Contents
77
==================================
88

99
.. toctree::
1010
:maxdepth: 3
11-
:caption: Home:
1211

1312
rst_files/datatype
1413
rst_files/format
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Converting PyTaco Datatype to Numpy
1+
Converting PyTaco Data Type to NumPy
22
======================================
33

4-
.. autofunction:: pytaco.as_np_dtype
4+
.. autofunction:: pytaco.as_np_dtype

python_bindings/source/rst_files/datatype.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Datatypes
1+
Data Types
22
========================
33

44
.. toctree::
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PyTaco Datatype Object
1+
PyTaco Data Type Object
22
=================================
33

4-
.. autoclass:: pytaco.dtype
4+
.. autoclass:: pytaco.dtype
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
.. _io:
22

3-
Tensor IO
3+
Tensor I/O
44
=================================
55

6-
PyTaco can read and write tensors natively from four different file formats. The formats PyTaco supports are:
6+
PyTaco can read and write tensors natively from three different file formats.
7+
The formats PyTaco supports are:
78

8-
`Matrix Market (Coordinate) Format <https://math.nist.gov/MatrixMarket/formats.html>`_ - .mtx
9-
10-
`Rutherford-Boeing Format <https://www.cise.ufl.edu/research/sparse/matrices/DOC/rb.pdf>`_ - .rb
11-
12-
`FROSTT Format <http://frostt.io/tensors/file-formats.html>`_ - .tns
13-
14-
For both the read and write functions, the file format is inferred from the file extension. This means that the
15-
extension must be given when specifying a file name.
9+
- `Matrix Market (Coordinate) Format <https://math.nist.gov/MatrixMarket/formats.html>`_ - .mtx
10+
- `Rutherford-Boeing Format <https://www.cise.ufl.edu/research/sparse/matrices/DOC/rb.pdf>`_ - .rb
11+
- `FROSTT Format <http://frostt.io/tensors/file-formats.html>`_ - .tns
1612

13+
For both the read and write functions, the file format is inferred from the
14+
file extension. This means that the extension must be given when specifying a
15+
file name.
1716

1817
.. currentmodule:: pytaco
1918

@@ -28,4 +27,4 @@ extension must be given when specifying a file name.
2827
to_array
2928
to_sp_csc
3029
to_sp_csr
31-
as_tensor
30+
as_tensor
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
PyTaco Index Vars
1+
PyTaco Index Variables
22
=======================
33
.. autoclass:: pytaco.index_var
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Evaluate String Expressions
2-
============================
1+
Evaluating String Expressions
2+
==============================
33

44
.. currentmodule:: pytaco
55

66
.. autosummary::
77
:toctree: functions
88

99
evaluate
10-
einsum
10+
einsum

python_bindings/source/rst_files/tensor_info.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,25 @@ Tensor Compute Functions
5757
outer
5858
tensordot
5959

60-
Tensor Manipulation functions
60+
Tensor Manipulation Functions
6161
===============================
6262
.. currentmodule:: pytaco
6363

6464
.. autosummary::
6565
:toctree: functions
6666

67-
tensor.insert
67+
tensor.transpose
6868
tensor.pack
6969
tensor.compile
70+
tensor.assemble
71+
tensor.compute
72+
tensor.evaluate
73+
tensor.to_dense
74+
tensor.to_array
75+
tensor.toarray
76+
tensor.to_sp_csr
77+
tensor.to_sp_csc
78+
tensor.copy
79+
tensor.insert
80+
tensor.remove_explicit_zeros
7081
remove_explicit_zeros

0 commit comments

Comments
 (0)