Skip to main content

RnnRecurrentImageState

Struct RnnRecurrentImageState 

Source
pub struct RnnRecurrentImageState { /* private fields */ }

Implementations§

Source§

impl RnnRecurrentImageState

Source

pub const fn as_ptr(&self) -> *mut c_void

Source§

impl RnnRecurrentImageState

Source

pub fn recurrent_output_image_for_layer_index( &self, layer_index: usize, ) -> Option<Image>

Examples found in repository?
examples/09_rnn_image_inference.rs (line 29)
4fn main() {
5    let device = MetalDevice::system_default().expect("no Metal device available");
6    let queue = device.new_command_queue().expect("command queue");
7
8    let single_gate = RnnSingleGateDescriptor::new(1, 1).expect("single gate descriptor");
9    single_gate.set_use_layer_input_unit_transform_mode(true);
10    let descriptor = single_gate.as_descriptor().expect("base descriptor");
11    let layer = RnnImageInferenceLayer::new(&device, &descriptor).expect("rnn layer");
12
13    let image_descriptor = ImageDescriptor::new(1, 1, 1, feature_channel_format::FLOAT32);
14    let src0 = Image::new(&device, image_descriptor).expect("src0");
15    let src1 = Image::new(&device, image_descriptor).expect("src1");
16    let dst0 = Image::new(&device, image_descriptor).expect("dst0");
17    let dst1 = Image::new(&device, image_descriptor).expect("dst1");
18    src0.write_f32(&[0.25]).expect("write src0");
19    src1.write_f32(&[0.75]).expect("write src1");
20
21    let command_buffer = queue.new_command_buffer().expect("command buffer");
22    let recurrent_state = layer
23        .encode_sequence(&command_buffer, &[&src0, &src1], &[&dst0, &dst1], None)
24        .expect("recurrent state");
25    command_buffer.commit();
26    command_buffer.wait_until_completed();
27
28    let recurrent_output = recurrent_state
29        .recurrent_output_image_for_layer_index(0)
30        .expect("recurrent output image");
31    println!(
32        "{:?} {}x{}x{}",
33        dst1.read_f32().expect("dst1 output"),
34        recurrent_output.width(),
35        recurrent_output.height(),
36        recurrent_output.feature_channels()
37    );
38}
Source

pub fn memory_cell_image_for_layer_index( &self, layer_index: usize, ) -> Option<Image>

Trait Implementations§

Source§

impl Drop for RnnRecurrentImageState

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for RnnRecurrentImageState

Source§

impl Sync for RnnRecurrentImageState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.