Skip to content

Commit

Permalink
Added print_shape for printing shape of operators (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffburdick authored Oct 15, 2024
1 parent ab9e7a1 commit c770d6c
Show file tree
Hide file tree
Showing 6 changed files with 1,028 additions and 1,218 deletions.
11 changes: 9 additions & 2 deletions docs_input/basics/print.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ the memory is on the host or device and print the tensor appropriately. The `pri
operator as the first parameter, and optionally the number of elements to print in each dimension. The
value of 0 is a special placeholder for "all", and using it prints all values in that dimension.

To print a tensor:
To print a tensor or operator:

.. code-block:: cpp
Expand All @@ -25,7 +25,7 @@ in a tensor is optional. The following code gives the same result:
auto t = make_tensor<TypeParam>({3});
print(ones(t.Shape()));
In this case MatX is printing data from the operator without going to the device.
By just printing the operator, MatX can materialize the data without going to device memory

To print only two elements:

Expand All @@ -42,6 +42,13 @@ element in the second dimension, and 10 elements in the last dimension.
auto t = make_tensor<TypeParam>({3, 10, 20});
print(ones(t.Shape()), 1, 0, 10);
To print just the shape and type of an operator, use `print_shape`:

.. code-block:: cpp
auto t = make_tensor<TypeParam>({3, 10, 20});
print_shape(ones(t.Shape()), 1, 0, 10);
Print Formatting Styles
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions include/matx.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "matx/core/half_complex.h"
#include "matx/core/half.h"
#include "matx/core/nvtx.h"
#include "matx/core/print.h"
#include "matx/core/pybind.h"
#include "matx/core/tensor.h"
#include "matx/core/tie.h"
Expand Down
1 change: 0 additions & 1 deletion include/matx/core/operator_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ namespace matx {

return shape;
}

namespace detail {
// Used inside of transforms to allocate temporary output
template <typename TensorType, typename Executor, typename ShapeType>
Expand Down
Loading

0 comments on commit c770d6c

Please sign in to comment.