Skip to content

Commit

Permalink
refactor/export: export important functionality from main module
Browse files Browse the repository at this point in the history
  • Loading branch information
hobofan committed Feb 3, 2016
1 parent c8d6e8c commit 4aea78d
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 44 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ to your Cargo manifest.
```rust
extern crate collenchyma as co;
extern crate collenchyma_nn as nn;
use co::backend::Backend;
use co::framework::IFramework;
use co::frameworks::{Cuda, Native};
use co::memory::MemoryType;
use co::tensor::SharedTensor;
use co::*;
use nn::*;

fn write_to_memory<T: Copy>(mem: &mut MemoryType, data: &[T]) {
Expand Down
19 changes: 14 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@
//! ```ignore
//! extern crate collenchyma as co;
//! extern crate collenchyma_nn as nn;
//! use co::backend::Backend;
//! use co::framework::IFramework;
//! use co::frameworks::{Cuda, Native};
//! use co::memory::MemoryType;
//! use co::tensor::SharedTensor;
//! use co::*;
//! use nn::*;
//!
//! fn write_to_memory<T: Copy>(mem: &mut MemoryType, data: &[T]) {
Expand Down Expand Up @@ -174,3 +170,16 @@ pub mod operation;
pub mod binary;
pub mod error;
pub mod plugin;

pub use backend::*;
pub use device::{IDevice, DeviceType};
pub use hardware::{IHardware, HardwareType};
pub use framework::IFramework;
pub use memory::{IMemory, MemoryType};
pub use tensor::{SharedTensor, TensorDesc, ITensorDesc, IntoTensorDesc};
#[cfg(feature = "native")]
pub use frameworks::Native;
#[cfg(feature = "cuda")]
pub use frameworks::Cuda;
#[cfg(feature = "opencl")]
pub use frameworks::OpenCL;
12 changes: 3 additions & 9 deletions tests/backend_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ extern crate libc;

#[cfg(test)]
mod backend_spec {


#[cfg(feature = "native")]
mod native {
use co::backend::{IBackend, Backend};
use co::frameworks::Native;
use co::*;

#[test]
fn it_can_create_default_backend() {
Expand All @@ -18,8 +15,7 @@ mod backend_spec {

#[cfg(feature = "cuda")]
mod cuda {
use co::backend::{IBackend, Backend};
use co::frameworks::Cuda;
use co::*;

#[test]
fn it_can_create_default_backend() {
Expand All @@ -29,9 +25,7 @@ mod backend_spec {

#[cfg(feature = "opencl")]
mod opencl {
use co::backend::{IBackend, Backend, BackendConfig};
use co::frameworks::OpenCL;
use co::framework::IFramework;
use co::*;

#[test]
fn it_can_create_default_backend() {
Expand Down
6 changes: 1 addition & 5 deletions tests/framework_cuda_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ extern crate libc;
#[cfg(test)]
#[cfg(feature = "cuda")]
mod framework_cuda_spec {
use co::backend::{IBackend, Backend};
use co::framework::IFramework;
use co::frameworks::Cuda;
use co::device::DeviceType;
use co::*;
use co::frameworks::cuda::memory::*;
use co::tensor::*;

#[test]
fn it_works() {
Expand Down
4 changes: 1 addition & 3 deletions tests/framework_native_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ extern crate collenchyma as co;
#[cfg(test)]
#[cfg(feature = "native")]
mod framework_native_spec {

use co::framework::IFramework;
use co::frameworks::Native;
use co::*;

#[test]
fn it_works() {
Expand Down
5 changes: 1 addition & 4 deletions tests/framework_opencl_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ extern crate libc;
#[cfg(test)]
#[cfg(feature = "opencl")]
mod framework_opencl_spec {

use co::device::DeviceType;
use co::framework::IFramework;
use co::frameworks::OpenCL;
use co::*;
use co::frameworks::opencl::memory::*;
use co::frameworks::opencl::queue::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/hardware_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern crate libc;
#[cfg(test)]
#[cfg(feature = "opencl")]
mod hardware_spec {
use co::hardware::{IHardware, HardwareType};
use co::*;
use co::frameworks::opencl::Device;

#[test]
Expand Down
11 changes: 1 addition & 10 deletions tests/shared_memory_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@ extern crate libc;

#[cfg(test)]
mod shared_memory_spec {

use co::framework::IFramework;
#[cfg(feature = "native")]
use co::frameworks::Native;
#[cfg(feature = "cuda")]
use co::frameworks::Cuda;
#[cfg(feature = "opencl")]
use co::frameworks::OpenCL;
use co::memory::MemoryType;
use co::tensor::*;
use co::*;

fn write_to_memory<T: Copy>(mem: &mut MemoryType, data: &[T]) {
match mem {
Expand Down
3 changes: 1 addition & 2 deletions tests/tensor_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ extern crate collenchyma as co;

#[cfg(test)]
mod tensor_spec {

use co::tensor::*;
use co::*;

#[test]
fn it_returns_correct_tensor_desc_stride() {
Expand Down

0 comments on commit 4aea78d

Please sign in to comment.