Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SunDoge committed Jul 18, 2023
1 parent e4424b8 commit 23008da
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/dl_managed_tensor_versioned.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
ffi::{self},
prelude::TensorView,
tensor::traits::TensorView,
};

// TODO: DLManagedTensor may be deprecated in the future.
Expand Down
13 changes: 8 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ mod device;
mod dl_managed_tensor;
mod dl_managed_tensor_versioned;
mod dl_tensor;
mod manager_ctx;
mod pack_version;
mod tensor;

#[cfg(feature = "pyo3")]
mod python;

/// Raw bindings for DLPack.
pub mod ffi;
pub mod manager_ctx;

/// Imports the structs and traits for you to implement [`IntoDLPack`] and [`FromDLPack`].
pub mod prelude;
pub mod tensor;

pub use manager_ctx::{CowIntArray, ManagerCtx};
pub use tensor::traits::{DLPack, FromDLPack, InferDtype, IntoDLPack, TensorView, ToTensor};
pub use tensor::ManagedTensor;
pub use crate::manager_ctx::{CowIntArray, ManagerCtx};
pub use crate::tensor::traits::{DLPack, FromDLPack, InferDtype, IntoDLPack, TensorView, ToTensor};
pub use crate::tensor::ManagedTensor;
5 changes: 2 additions & 3 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub use crate::ffi::{DataType, Device, PackVersion};
pub use crate::manager_ctx::{CowIntArray, ManagerCtx};
pub use crate::tensor::traits::{DLPack, FromDLPack, InferDtype, TensorView, IntoDLPack, ToTensor};
pub use crate::tensor::ManagedTensor;
pub use crate::tensor::traits::{DLPack, FromDLPack, InferDtype, IntoDLPack, TensorView, ToTensor};
pub use crate::{CowIntArray, ManagedTensor, ManagerCtx};
3 changes: 3 additions & 0 deletions src/tensor/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub trait InferDtype {
fn infer_dtype() -> DataType;
}

/// Access Tensor data.
pub trait TensorView {
/// Get untyped data ptr
fn data_ptr(&self) -> *mut std::ffi::c_void;
Expand Down Expand Up @@ -81,11 +82,13 @@ pub trait ToTensor {

// TODO: we should add `try_to_dlpack` fn
// We may have to define error type for this.
/// Convert into [`DLPack`](crate::DLPack)
pub trait IntoDLPack {
fn into_dlpack(self) -> DLPack;
}

// TODO: we should add `try_from_dlpack` fn
/// Make Tensor from [`DLPack`](crate::DLPack)
pub trait FromDLPack {
// TODO: DLManagedTensor will be deprecated in th future.
fn from_dlpack(dlpack: DLPack) -> Self;
Expand Down

0 comments on commit 23008da

Please sign in to comment.