data sync before get tensor value

This commit is contained in:
looop5 2022-12-16 11:16:05 +08:00
parent 3797dad108
commit ece00fff3a
1 changed files with 3 additions and 0 deletions

View File

@ -208,6 +208,9 @@ int64_t GetIntValue(const NodePtr &node) { return AnfUtils::GetIntValue(node->ge
std::vector<int64_t> GetIntList(const ValuePtr &value) {
MS_EXCEPTION_IF_NULL(value);
if (value->isa<tensor::Tensor>()) {
auto tensor = value->cast<tensor::TensorPtr>();
MS_EXCEPTION_IF_NULL(tensor);
tensor->data_sync();
return CheckAndConvertUtils::CheckTensorIntValue("tensor", value, "bprop");
} else {
return CheckAndConvertUtils::CheckIntOrTupleInt("value", value, "bprop");