objc2_ml_compute/generated/
MLCMultiheadAttentionLayer.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10    /// A multi-head attention layer
11    ///
12    /// A multi-head "Scaled Dot-Product Attention" layer which attends to one or more entries in the input key-value pairs
13    /// N=Batch, S=source length, L=target length, E = model(embedding) dimension, K = Key dimension, V = value
14    /// dimension H = headCount. The sources to this layer are of shapes: Query:(N,L,E), Key:(N,S,K), Value:(N,S,V),
15    /// KeyMask:(N,S), AttentionMask:(1,L,S) or (NxH,L,S). KeyMask and AttentionMask are optional and either, both
16    /// or none of them can be passed. KeyMask is of Boolean type and AttentionMask can be of Float or Boolean type.
17    /// Output is of shape:(N,L,E).
18    /// For details refer to: https://pytorch.org/docs/stable/nn.html#multiheadattention
19    ///
20    /// See also [Apple's documentation](https://developer.apple.com/documentation/mlcompute/mlcmultiheadattentionlayer?language=objc)
21    #[unsafe(super(MLCLayer, NSObject))]
22    #[derive(Debug, PartialEq, Eq, Hash)]
23    #[cfg(feature = "MLCLayer")]
24    #[deprecated]
25    pub struct MLCMultiheadAttentionLayer;
26);
27
28#[cfg(feature = "MLCLayer")]
29extern_conformance!(
30    unsafe impl NSObjectProtocol for MLCMultiheadAttentionLayer {}
31);
32
33#[cfg(feature = "MLCLayer")]
34impl MLCMultiheadAttentionLayer {
35    extern_methods!(
36        #[cfg(feature = "MLCMultiheadAttentionDescriptor")]
37        /// The multi-head attention descriptor
38        #[deprecated]
39        #[unsafe(method(descriptor))]
40        #[unsafe(method_family = none)]
41        pub unsafe fn descriptor(&self) -> Retained<MLCMultiheadAttentionDescriptor>;
42
43        #[cfg(feature = "MLCTensor")]
44        /// The weights of query, key, value and output projections
45        #[deprecated]
46        #[unsafe(method(weights))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn weights(&self) -> Retained<NSArray<MLCTensor>>;
49
50        #[cfg(feature = "MLCTensor")]
51        /// The biases of query, key, value and output projections
52        #[deprecated]
53        #[unsafe(method(biases))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn biases(&self) -> Option<Retained<NSArray<MLCTensor>>>;
56
57        #[cfg(feature = "MLCTensor")]
58        /// The biases added to key and value
59        #[deprecated]
60        #[unsafe(method(attentionBiases))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn attentionBiases(&self) -> Option<Retained<NSArray<MLCTensor>>>;
63
64        #[cfg(feature = "MLCTensorParameter")]
65        /// The weights tensor parameters used for optimizer update
66        #[deprecated]
67        #[unsafe(method(weightsParameters))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn weightsParameters(&self) -> Retained<NSArray<MLCTensorParameter>>;
70
71        #[cfg(feature = "MLCTensorParameter")]
72        /// The biases tensor parameters used for optimizer update
73        #[deprecated]
74        #[unsafe(method(biasesParameters))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn biasesParameters(&self) -> Option<Retained<NSArray<MLCTensorParameter>>>;
77
78        #[cfg(all(feature = "MLCMultiheadAttentionDescriptor", feature = "MLCTensor"))]
79        /// Create a multi-head attention layer
80        ///
81        /// Parameter `weights`: weights corresponding to query, key, value and output projections for all heads
82        ///
83        /// Parameter `biases`: Optional, biases corresponding to query, key, value and output projections for all heads
84        ///
85        /// Parameter `attentionBiases`: Optional, An array of biases added to the key and value respectively
86        ///
87        /// Returns: A new MultiheadAttention layer
88        #[deprecated]
89        #[unsafe(method(layerWithDescriptor:weights:biases:attentionBiases:))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn layerWithDescriptor_weights_biases_attentionBiases(
92            descriptor: &MLCMultiheadAttentionDescriptor,
93            weights: &NSArray<MLCTensor>,
94            biases: Option<&NSArray<MLCTensor>>,
95            attention_biases: Option<&NSArray<MLCTensor>>,
96        ) -> Option<Retained<Self>>;
97    );
98}
99
100/// Methods declared on superclass `MLCLayer`.
101#[cfg(feature = "MLCLayer")]
102impl MLCMultiheadAttentionLayer {
103    extern_methods!(
104        #[deprecated]
105        #[unsafe(method(new))]
106        #[unsafe(method_family = new)]
107        pub unsafe fn new() -> Retained<Self>;
108
109        #[deprecated]
110        #[unsafe(method(init))]
111        #[unsafe(method_family = init)]
112        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
113    );
114}