Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Sparse Matrix APIs #1279

Merged
merged 62 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
8acda77
Thinking through initial interfaces
cjnolet Feb 14, 2023
c3a701d
Continuing to work on sparse designs
cjnolet Feb 15, 2023
684fed1
I think the design is just aobut there.
cjnolet Feb 15, 2023
e1baa4f
Adding factories for structure and views
cjnolet Feb 15, 2023
1b8ef76
Getting there...
cjnolet Feb 15, 2023
eacfd0f
Test passing. Writing more tests
cjnolet Feb 15, 2023
b220cce
Added very basic csr test
cjnolet Feb 15, 2023
14cfed3
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Feb 15, 2023
769d4d4
Merge remote-tracking branch 'rapidsai/branch-23.04' into fea-2304-sp…
cjnolet Feb 15, 2023
cc090a0
Merge branch 'fea-2304-sparse_matrix' of github.com:cjnolet/raft into…
cjnolet Feb 15, 2023
dc519ce
Adding more docs to the public API for new sparse types
cjnolet Feb 16, 2023
788113f
Using a common base for matrix types. need to figure out a clever way…
cjnolet Feb 16, 2023
70edcd4
Correcting template
cjnolet Feb 16, 2023
d84851d
Divye and I finally got it- we can accept a sparse_matrix now without…
cjnolet Feb 17, 2023
f14d679
Splitting sparse impls into difference files
cjnolet Feb 17, 2023
72be283
Trying type traits
cjnolet Feb 17, 2023
9804e87
Fixing bug
cjnolet Feb 17, 2023
389db97
Adding example of testing if function input is device_csr_matrix
cjnolet Feb 17, 2023
4168d0b
Almost there....
cjnolet Feb 17, 2023
d3bcb97
Using type_enum only from csr_matrix
cjnolet Feb 17, 2023
46304e8
A couple little updates
cjnolet Feb 17, 2023
4e8362f
Added typedefs for template types to csr classes
cjnolet Feb 17, 2023
9b66cbc
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Feb 17, 2023
d132021
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Feb 18, 2023
c4dfb9a
Fixing failing docs (and a warning)
cjnolet Feb 18, 2023
b679b75
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Feb 20, 2023
f136f6a
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Feb 22, 2023
39b66bf
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Feb 25, 2023
d3b1390
Update cpp/include/raft/core/csr_matrix.hpp
cjnolet Feb 27, 2023
fd0a38c
Making host variants and running into some issues
cjnolet Mar 1, 2023
fddaa47
Merge branch 'fea-2304-sparse_matrix' of github.com:cjnolet/raft into…
cjnolet Mar 1, 2023
5a40419
Still trying to figure it out
cjnolet Mar 1, 2023
e2fb871
Adding host api for sparse
cjnolet Mar 1, 2023
74053a8
Fixing build
cjnolet Mar 1, 2023
0338d29
Fixing some remaining issues
cjnolet Mar 1, 2023
47ebe27
Reverting some unecessary changes
cjnolet Mar 1, 2023
d8b2df1
Reverting more unecessary changes
cjnolet Mar 1, 2023
b5fa578
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Mar 2, 2023
d9a760c
Fixing benchmarks for updated mdarray changes
cjnolet Mar 6, 2023
9c10ce6
Adding usage examples to factory functions
cjnolet Mar 6, 2023
b852de0
Fixing docs
cjnolet Mar 6, 2023
71c4d43
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Mar 7, 2023
7ccc6a1
Adding to googletests and fixing resulting things
cjnolet Mar 7, 2023
68ffcb6
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Mar 9, 2023
1544af8
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Mar 11, 2023
6f58873
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Mar 12, 2023
d4f715d
Merge branch 'branch-23.04' into fea-2304-sparse_matrix
cjnolet Mar 14, 2023
182b1d2
Fixign compile error
cjnolet Mar 14, 2023
c56a1f2
Merge branch 'fea-2304-sparse_matrix' of github.com:cjnolet/raft into…
cjnolet Mar 14, 2023
9573036
Removing setup.cfg
cjnolet Mar 14, 2023
c5f2283
Fixing temporary device buffer
cjnolet Mar 14, 2023
ffd60bb
Fixes
cjnolet Mar 14, 2023
1a41f98
Update cpp/include/raft/core/coo_matrix.hpp
cjnolet Mar 14, 2023
438f0c6
Update cpp/include/raft/core/coo_matrix.hpp
cjnolet Mar 14, 2023
f0a32a9
Update cpp/include/raft/core/coo_matrix.hpp
cjnolet Mar 14, 2023
fffbcb2
Reverting the `std::enable_if_t` -> std::enable_if seems to compile a…
cjnolet Mar 14, 2023
350719b
Implementing review feedback
cjnolet Mar 14, 2023
0e644b6
Adding device resources
cjnolet Mar 14, 2023
8b1d580
Adding device resources to ivf pq types
cjnolet Mar 14, 2023
581b29b
Merge remote-tracking branch 'rapidsai/branch-23.04' into fea-2304-sp…
cjnolet Mar 15, 2023
4c00fe5
Updates
cjnolet Mar 15, 2023
d478ac4
Fixing ivf-flat serialize
cjnolet Mar 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
I think the design is just aobut there.
  • Loading branch information
cjnolet committed Feb 15, 2023
commit 684fed1fcf3ef1e9416e933bbb3f379790e384cd
153 changes: 153 additions & 0 deletions cpp/include/raft/core/device_sparse_matrix.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once

#include <raft/core/detail/device_mdarray.hpp>
#include <raft/core/sparse_matrix.hpp>

namespace raft {

template <typename ElementType,
typename IndptrType,
typename IndicesType,
typename NZType,
typename ContainerPolicy = detail::device_uvector_policy<ElementType>>
using device_structure_owning_csr_matrix =
structure_owning_csr_matrix<ElementType, IndptrType, IndicesType, NZType, true, ContainerPolicy>

template <typename ElementType,
typename IndptrType,
typename IndicesType,
typename NZType,
typename ContainerPolicy = detail::device_uvector_policy<ElementType>>
using device_structure_preserving_csr_matrix = structure_preserving_csr_matrix<ElementType,
IndptrType,
IndicesType,
NZType,
true,
ContainerPolicy>

template <typename ElementType,
typename RowType,
typename ColType,
typename NZType,
typename ContainerPolicy = detail::device_uvector_policy<ElementType>>
using device_structure_owning_coo_matrix =
structure_owning_coo_matrix<ElementType, RowType, ColType, NZType, true, ContainerPolicy>

template <typename ElementType,
typename RowType,
typename ColType,
typename NZType,
typename ContainerPolicy = detail::device_uvector_policy<ElementType>>
using device_structure_preserving_coo_matrix =
structure_preserving_coo_matrix<ElementType, RowType, ColType, NZType, true, ContainerPolicy>

/**
* Create a structure-owning sparse matrix in the compressed-sparse row format. Structure-owning
* means that all of the underlying vectors (data, indptr, indices) are owned by the csr_matrix
* instance. If not known up front, the sparsity can be ignored in this factory function and
* `resize()` invoked on the instance once the sparsity is known.
* @tparam ElementType
* @tparam IndptrType
* @tparam IndicesType
* @tparam NZType
* @param handle
* @param n_rows
* @param n_cols
* @param nnz
* @return
*/
template <typename ElementType, typename IndptrType, typename IndicesType, typename NZType>
auto make_csr_matrix(raft::device_resources const& handle,
IndptrType n_rows,
IndicesType n_cols,
NZType nnz = 0)
{
using csr_matrix_t =
device_structure_owning_csr_matrix<ElementType, IndptrType, IndicesType, NZType>;
return csr_matrix_t(handle, n_rows, n_cols, nnz);
}

/**
* Create a structure-preserving sparse matrix in the compressed-sparse row format.
* Structure-preserving means that a view of the csr structure is supplied, allowing the values in
* the structure to change but not the structure itself. The csr_matrix instance does not own the
* structure, the sparsity must be known up front, and cannot be resized later.
* @tparam ElementType
* @tparam IndptrType
* @tparam IndicesType
* @tparam NZType
* @param handle
* @param structure_
* @return
*/
template <typename ElementType, typename IndptrType, typename IndicesType, typename NZType>
auto make_csr_matrix(raft::device_resources const& handle,
compressed_structure_view<IndptrType, IndicesType, NZType> structure_)
{
using csr_matrix_t =
device_structure_preserving_csr_matrix<ElementType, IndptrType, IndicesType, NZType>;
return csr_matrix_t(handle, std::make_shared(structure_));
}

/**
* Create a structure-owning sparse matrix in the coordinate format. Structure-owning means that
* all of the underlying vectors (data, indptr, indices) are owned by the coo_matrix instance. If
* not known up front, the sparsity can be ignored in this factory function and `resize()` invoked
* on the instance once the sparsity is known.
* @tparam ElementType
* @tparam IndptrType
* @tparam IndicesType
* @tparam NZType
* @param handle
* @param n_rows
* @param n_cols
* @param nnz
* @return
*/
template <typename ElementType, typename RowType, typename ColType, typename NZType>
auto make_coo_matrix(raft::device_resources const& handle,
RowType n_rows,
ColType n_cols,
NZType nnz = 0)
{
using coo_matrix_t = device_structure_owning_coo_matrix<ElementType, RowType, ColType, NZType>;
return coo_matrix_t(handle, n_rows, n_cols, nnz);
}

/**
* Create a structure-preserving sparse matrix in the coordinate format. Structure-preserving means
* that a view of the coo structure is supplied, allowing the values in the structure to change but
* not the structure itself. The csr_matrix instance does not own the structure, the sparsity must
* be known up front, and cannot be resized later.
* @tparam ElementType
* @tparam IndptrType
* @tparam IndicesType
* @tparam NZType
* @param handle
* @param structure_
* @return
*/
template <typename ElementType, typename RowType, typename ColType, typename NZType>
auto make_coo_matrix(raft::device_resources const& handle,
coordinate_structure_view<RowType, ColType, NZType> structure_)
{
using coo_matrix_t =
device_structure_preserving_coo_matrix<ElementType, RowType, ColType, NZType>;
return coo_matrix_t(handle, std::make_shared(structure_));
}
}; // namespace raft
Loading