File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# limitations under the License.
14+ import inspect
1415from importlib import import_module
1516from typing import Callable , Optional , Union
1617
@@ -509,6 +510,15 @@ def forward(
509510 # The `Attention` class can call different attention processors / attention functions
510511 # here we simply pass along all tensors to the selected processor class
511512 # For standard processors that are defined here, `**cross_attention_kwargs` is empty
513+
514+ attn_parameters = set (inspect .signature (self .processor .__call__ ).parameters .keys ())
515+ unused_kwargs = [k for k , _ in cross_attention_kwargs .items () if k not in attn_parameters ]
516+ if len (unused_kwargs ) > 0 :
517+ logger .warning (
518+ f"cross_attention_kwargs { unused_kwargs } are not expected by { self .processor .__class__ .__name__ } and will be ignored."
519+ )
520+ cross_attention_kwargs = {k : w for k , w in cross_attention_kwargs .items () if k in attn_parameters }
521+
512522 return self .processor (
513523 self ,
514524 hidden_states ,
You can’t perform that action at this time.
0 commit comments