mirror of
				https://github.com/facebookresearch/pytorch3d.git
				synced 2025-11-04 09:52:11 +08:00 
			
		
		
		
	Error instead of crash for tensors on exotic devices
Summary: Adds CHECK_CPU macros that checks if a tensor is on the CPU device throughout csrc directories up to `marching_cubes`. Directories updated include those in `gather_scatter`, `interp_face_attrs`, `iou_box3d`, `knn`, and `marching_cubes`. Note that this is the second part of a larger change, and to keep diffs better organized, subsequent diffs will update the remaining directories. Reviewed By: bottler Differential Revision: D77558550 fbshipit-source-id: 762a0fe88548dc8d0901b198a11c40d0c36e173f
This commit is contained in:
		
							parent
							
								
									267bd8ef87
								
							
						
					
					
						commit
						3ff6c5ab85
					
				@ -53,5 +53,7 @@ at::Tensor GatherScatter(
 | 
			
		||||
    AT_ERROR("Not compiled with GPU support.");
 | 
			
		||||
#endif
 | 
			
		||||
  }
 | 
			
		||||
  CHECK_CPU(input);
 | 
			
		||||
  CHECK_CPU(edges);
 | 
			
		||||
  return GatherScatterCpu(input, edges, directed, backward);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -57,6 +57,8 @@ at::Tensor InterpFaceAttrsForward(
 | 
			
		||||
    AT_ERROR("Not compiled with GPU support.");
 | 
			
		||||
#endif
 | 
			
		||||
  }
 | 
			
		||||
  CHECK_CPU(face_attrs);
 | 
			
		||||
  CHECK_CPU(barycentric_coords);
 | 
			
		||||
  return InterpFaceAttrsForwardCpu(pix_to_face, barycentric_coords, face_attrs);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -106,6 +108,9 @@ std::tuple<at::Tensor, at::Tensor> InterpFaceAttrsBackward(
 | 
			
		||||
    AT_ERROR("Not compiled with GPU support.");
 | 
			
		||||
#endif
 | 
			
		||||
  }
 | 
			
		||||
  CHECK_CPU(face_attrs);
 | 
			
		||||
  CHECK_CPU(barycentric_coords);
 | 
			
		||||
  CHECK_CPU(grad_pix_attrs);
 | 
			
		||||
  return InterpFaceAttrsBackwardCpu(
 | 
			
		||||
      pix_to_face, barycentric_coords, face_attrs, grad_pix_attrs);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -44,5 +44,7 @@ inline std::tuple<at::Tensor, at::Tensor> IoUBox3D(
 | 
			
		||||
    AT_ERROR("Not compiled with GPU support.");
 | 
			
		||||
#endif
 | 
			
		||||
  }
 | 
			
		||||
  CHECK_CPU(boxes1);
 | 
			
		||||
  CHECK_CPU(boxes2);
 | 
			
		||||
  return IoUBox3DCpu(boxes1.contiguous(), boxes2.contiguous());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -74,6 +74,8 @@ std::tuple<at::Tensor, at::Tensor> KNearestNeighborIdx(
 | 
			
		||||
    AT_ERROR("Not compiled with GPU support.");
 | 
			
		||||
#endif
 | 
			
		||||
  }
 | 
			
		||||
  CHECK_CPU(p1);
 | 
			
		||||
  CHECK_CPU(p2);
 | 
			
		||||
  return KNearestNeighborIdxCpu(p1, p2, lengths1, lengths2, norm, K);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -140,6 +142,8 @@ std::tuple<at::Tensor, at::Tensor> KNearestNeighborBackward(
 | 
			
		||||
    AT_ERROR("Not compiled with GPU support.");
 | 
			
		||||
#endif
 | 
			
		||||
  }
 | 
			
		||||
  CHECK_CPU(p1);
 | 
			
		||||
  CHECK_CPU(p2);
 | 
			
		||||
  return KNearestNeighborBackwardCpu(
 | 
			
		||||
      p1, p2, lengths1, lengths2, idxs, norm, grad_dists);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -58,5 +58,6 @@ inline std::tuple<at::Tensor, at::Tensor, at::Tensor> MarchingCubes(
 | 
			
		||||
    AT_ERROR("Not compiled with GPU support.");
 | 
			
		||||
#endif
 | 
			
		||||
  }
 | 
			
		||||
  CHECK_CPU(vol);
 | 
			
		||||
  return MarchingCubesCpu(vol.contiguous(), isolevel);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user