Skip to content

Commit

Permalink
Merge pull request #20 from boydjohnson/feature/reorg
Browse files Browse the repository at this point in the history
Reorganize tests, put primitives in primitives mod
  • Loading branch information
boydjohnson authored Jan 11, 2025
2 parents d01f380 + bb11623 commit 4227752
Show file tree
Hide file tree
Showing 17 changed files with 515 additions and 507 deletions.
7 changes: 2 additions & 5 deletions benches/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ use {
format_tag::x,
Memory,
},
primitive::{
attributes::PrimitiveAttributes,
config::binary::{Binary, ForwardBinary, ForwardBinaryConfig},
ExecArg, Primitive, PropForwardInference,
},
primitive::{attributes::PrimitiveAttributes, ExecArg, Primitive, PropForwardInference},
primitives::binary::{Binary, ForwardBinary, ForwardBinaryConfig},
set_primitive_cache_capacity,
stream::Stream,
},
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod engine;
pub mod error;
pub mod memory;
pub mod primitive;
pub mod primitives;
pub mod stream;

use error::DnnlError;
Expand Down
5 changes: 2 additions & 3 deletions src/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,9 @@ impl Primitive {
/// engine::Engine,
/// memory::{descriptor::MemoryDescriptor, format_tag::x},
/// primitive::{
/// attributes::PrimitiveAttributes,
/// config::binary::{ForwardBinary, ForwardBinaryConfig},
/// Forward, Primitive, PropForwardInference,
/// attributes::PrimitiveAttributes, Forward, Primitive, PropForwardInference,
/// },
/// primitives::binary::{ForwardBinary, ForwardBinaryConfig},
/// },
/// onednnl_sys::{dnnl_alg_kind_t, dnnl_data_type_t::dnnl_f32},
/// };
Expand Down
9 changes: 0 additions & 9 deletions src/primitive/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ use {
std::sync::Arc,
};

pub mod au_gru;
pub mod batch_norm;
pub mod binary;
pub mod eltwise;
pub mod inner_product;
pub mod matmul;
pub mod prelu;
pub mod reduction;

pub trait PrimitiveConfig<'a, D: Direction, P: PropType<D>> {
fn create_primitive_desc(&self, engine: Arc<Engine>) -> Result<PrimitiveDescriptor, DnnlError>;
}
7 changes: 3 additions & 4 deletions src/primitive/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ impl PrimitiveDescriptor {
/// engine::Engine,
/// memory::{descriptor::MemoryDescriptor, format_tag::x},
/// primitive::{
/// attributes::PrimitiveAttributes,
/// config::binary::{ForwardBinary, ForwardBinaryConfig},
/// descriptor::PrimitiveDescriptor,
/// Forward, PropForwardInference,
/// attributes::PrimitiveAttributes, descriptor::PrimitiveDescriptor, Forward,
/// PropForwardInference,
/// },
/// primitives::binary::{ForwardBinary, ForwardBinaryConfig},
/// },
/// onednnl_sys::{dnnl_alg_kind_t, dnnl_data_type_t::dnnl_f32},
/// };
Expand Down
8 changes: 8 additions & 0 deletions src/primitives.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub mod au_gru;
pub mod batch_norm;
pub mod binary;
pub mod eltwise;
pub mod inner_product;
pub mod matmul;
pub mod prelu;
pub mod reduction;
5 changes: 2 additions & 3 deletions src/primitive/config/au_gru.rs → src/primitives/au_gru.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use {
super::PrimitiveConfig,
crate::{
engine::Engine,
error::DnnlError,
memory::descriptor::MemoryDescriptor,
primitive::{
attributes::PrimitiveAttributes, descriptor::PrimitiveDescriptor, Backward, Forward,
Operation, OperationType, PropType,
attributes::PrimitiveAttributes, config::PrimitiveConfig,
descriptor::PrimitiveDescriptor, Backward, Forward, Operation, OperationType, PropType,
},
},
onednnl_sys::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ use {
crate::{
memory::descriptor::MemoryDescriptor,
primitive::{
attributes::PrimitiveAttributes, descriptor::PrimitiveDescriptor, Forward, Operation,
OperationType, PropType,
attributes::PrimitiveAttributes, config::PrimitiveConfig,
descriptor::PrimitiveDescriptor, Forward, Operation, OperationType, PropType,
},
},
onednnl_sys::{dnnl_batch_normalization_forward_primitive_desc_create, dnnl_status_t},
std::ffi::c_uint,
};

use super::PrimitiveConfig;

pub struct ForwardBatchNormConfig<'a> {
src_desc: &'a MemoryDescriptor,
dst_desc: &'a MemoryDescriptor,
Expand Down
6 changes: 3 additions & 3 deletions src/primitive/config/binary.rs → src/primitives/binary.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use {
super::PrimitiveConfig,
crate::{
memory::descriptor::MemoryDescriptor,
primitive::{
attributes::PrimitiveAttributes, descriptor::PrimitiveDescriptor, Forward, Operation,
OperationType, PropForwardInference, PropType,
attributes::PrimitiveAttributes, config::PrimitiveConfig,
descriptor::PrimitiveDescriptor, Forward, Operation, OperationType,
PropForwardInference, PropType,
},
},
onednnl_sys::{dnnl_alg_kind_t, dnnl_binary_primitive_desc_create, dnnl_status_t},
Expand Down
5 changes: 2 additions & 3 deletions src/primitive/config/eltwise.rs → src/primitives/eltwise.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use {
super::PrimitiveConfig,
crate::{
memory::descriptor::MemoryDescriptor,
primitive::{
attributes::PrimitiveAttributes, descriptor::PrimitiveDescriptor, Backward, Forward,
Operation, OperationType, PropType,
attributes::PrimitiveAttributes, config::PrimitiveConfig,
descriptor::PrimitiveDescriptor, Backward, Forward, Operation, OperationType, PropType,
},
},
onednnl_sys::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use {
super::PrimitiveConfig,
crate::{
memory::descriptor::MemoryDescriptor,
primitive::{
attributes::PrimitiveAttributes, descriptor::PrimitiveDescriptor, Backward, Forward,
Operation, OperationType, PropBackwardData, PropBackwardWeights, PropType,
attributes::PrimitiveAttributes, config::PrimitiveConfig,
descriptor::PrimitiveDescriptor, Backward, Forward, Operation, OperationType,
PropBackwardData, PropBackwardWeights, PropType,
},
},
onednnl_sys::{
Expand Down
5 changes: 2 additions & 3 deletions src/primitive/config/matmul.rs → src/primitives/matmul.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use {
super::PrimitiveConfig,
crate::{
memory::descriptor::MemoryDescriptor,
primitive::{
attributes::PrimitiveAttributes, descriptor::PrimitiveDescriptor, Forward, Operation,
OperationType, PropType,
attributes::PrimitiveAttributes, config::PrimitiveConfig,
descriptor::PrimitiveDescriptor, Forward, Operation, OperationType, PropType,
},
},
onednnl_sys::{dnnl_matmul_primitive_desc_create, dnnl_status_t},
Expand Down
15 changes: 6 additions & 9 deletions src/primitive/config/prelu.rs → src/primitives/prelu.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use {
super::PrimitiveConfig,
crate::{
memory::descriptor::MemoryDescriptor,
onednnl_sys::{dnnl_prelu_forward_primitive_desc_create, dnnl_status_t},
primitive::{
attributes::PrimitiveAttributes, descriptor::PrimitiveDescriptor, Forward, Operation,
OperationType, PropType,
},
use crate::{
memory::descriptor::MemoryDescriptor,
onednnl_sys::{dnnl_prelu_forward_primitive_desc_create, dnnl_status_t},
primitive::{
attributes::PrimitiveAttributes, config::PrimitiveConfig, descriptor::PrimitiveDescriptor,
Forward, Operation, OperationType, PropType,
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use {
super::PrimitiveConfig,
crate::{
memory::descriptor::MemoryDescriptor,
primitive::{
attributes::PrimitiveAttributes, descriptor::PrimitiveDescriptor, Forward, Operation,
OperationType, PropForwardInference,
attributes::PrimitiveAttributes, config::PrimitiveConfig,
descriptor::PrimitiveDescriptor, Forward, Operation, OperationType,
PropForwardInference,
},
},
onednnl_sys::{dnnl_alg_kind_t, dnnl_reduction_primitive_desc_create, dnnl_status_t},
Expand Down
Loading

0 comments on commit 4227752

Please sign in to comment.