tests: fix pytorch tensor placement errors (#33485)
This commit fixes the following errors: * Fix "expected all tensors to be on the same device" error * Fix "can't convert device type tensor to numpy" According to pytorch documentation torch.Tensor.numpy(force=False) performs conversion only if tensor is on CPU (plus few other restrictions) which is not the case. For our case we need force=True since we just need a data and don't care about tensors coherency. Fixes: #33517 See: https://pytorch.org/docs/2.4/generated/torch.Tensor.numpy.html Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
This commit is contained in:
@@ -170,7 +170,7 @@ class InformerModelTester:
|
||||
|
||||
embed_positions = InformerSinusoidalPositionalEmbedding(
|
||||
config.context_length + config.prediction_length, config.d_model
|
||||
)
|
||||
).to(torch_device)
|
||||
self.parent.assertTrue(torch.equal(model.encoder.embed_positions.weight, embed_positions.weight))
|
||||
self.parent.assertTrue(torch.equal(model.decoder.embed_positions.weight, embed_positions.weight))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user