打开微信,使用扫一扫进入页面后,点击右上角菜单,
点击“发送给朋友”或“分享到朋友圈”完成分享
这个是生成cambricon的代码,然后这个model,我在测试的时候也有输出模型内传没传过去参数,是传过去的
下面的是一个测试案例
def forward( self, inputs_ids: torch.LongTensor = None, causal_mask_shape: torch.LongTensor = None, position_ids: Optional[torch.LongTensor] = None, cache_position: torch.LongTensor = None, ) -> Union[Tuple, ModelOutputWithPast]: dtype, device = inputs_ids.dtype, inputs_ids.device inputs_ids = inputs_ids.to(device) causal_mask_shape = causal_mask_shape.to(device) position_ids = position_ids.to(device) if position_ids is not None else None cache_position = cache_position.to(device) print(f"inputs_ids device: {inputs_ids.device}, dtype: {inputs_ids.dtype}") print(f"causal_mask_shape device: {causal_mask_shape.device}, dtype: {causal_mask_shape.dtype}") print(f"position_ids device: {position_ids.device if position_ids is not None else 'None'}") print(f"cache_position device: {cache_position.device}") if 'mlu' in str(device): print(f"causal_mask device: {causal_mask.device}") print(f"causal_mask: {causal_mask.to('cpu')}") else: causal_mask = torch.tensor([[1.0, 2.0], [3.0, 4.0]], dtype=dtype, device=device) # 返回结果 return causal_mask
但是总是报错
热门帖子
精华帖子