Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions oneflow/core/functional/impl/array_functor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,27 @@ class ArgWhereFunctor {
const Symbol<DType>& dtype) const {
auto& attrs = THREAD_CACHED_MUTABLE_ATTR_MAP("dtype");
attrs.SetAllAttrs(dtype->data_type());
#ifdef WITH_NPU
auto device_type = DeviceType::kCPU;
if (x->is_global()) {
device_type = JUST(x->parallel_desc())->device_type();
} else {
device_type = JUST(x->device())->enum_type();
}
if (device_type == DeviceType::kNPU) {
// NOTE: use cpu argwhere when device="npu"
auto cpu_tensor = JUST(one::functional::To(x, "cpu"));
auto result = JUST(OpInterpUtil::Dispatch<TensorTuple>(*op_, {cpu_tensor}, attrs));
for (int i = 0; i < result->size(); ++i) {
(*result)[i] = JUST(one::functional::To((*result)[i], "npu"));
}
return result;
} else {
return OpInterpUtil::Dispatch<TensorTuple>(*op_, {x}, attrs);
}
#else
return OpInterpUtil::Dispatch<TensorTuple>(*op_, {x}, attrs);
#endif // WITH_NPU
}

private:
Expand Down
Loading