AttributeError: 'NoneType' object has no attribute 'flatten'. Intel OneAPI optimisation introduces error #265
-
So I'm trying out this Intel OneAPI to utilise hardware optimisation of Intel CPU. I believe they have their own implementations for layers and modules that act as a wrapper around torch modules. Here is the minimal reproducible code for you to test out: import torch
import intel_extension_for_pytorch as ipex
import torchxrayvision as xrv
from torchcam.methods import GradCAM
input_tensor = torch.rand((1, 1, 224, 224))
model = xrv.models.DenseNet(weights="densenet121-res224-all")
model = ipex.optimize(model, dtype=torch.float32)
target_layer = model.features.get_submodule("denseblock4.denselayer16.conv2")
cam = GradCAM(model, target_layer)
scores = model(input_tensor)
cam(class_idx=1, scores=scores) So I believe the Here is the stack trace for the error.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hey @karnikkanojia 👋 I don't know about Intel OneAPI so I'm not sure I can help much. Have you tried commenting the line |
Beta Was this translation helpful? Give feedback.
Hey @karnikkanojia 👋
I don't know about Intel OneAPI so I'm not sure I can help much. Have you tried commenting the line
model = ipex.optimize(model, dtype=torch.float32)
. If it works when you're commenting that, most likely,ipex
changes things related to the pytorch hooks and are not, by default, compatible with torchcam I'm afraid