[caffe2] EnforceFinite: log blobs finiteness in workspace on error (#52892)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52892
When an EnforceFinite check fails this logs all of the tensors in the workspace and whether they are finite or not.
This is a little bit hacky since it uses the aten APIs. I've `ifdef`ed the implementation so it should compile fine on xplat and mobile. It's also accessing the workspace directly but since this is a logging op it seems fine to bend the rules.
Test Plan:
$ buck test //caffe2/caffe2/python/operator_test:enforce_finite_op_test
$ buck-out/gen/caffe2/caffe2/python/operator_test/enforce_finite_op_test#binary.par
I0225 16:29:46.166507 311548 enforce_finite_op.h:62] blob X isfinite=false
Reviewed By: dzhulgakov
Differential Revision: D26626336
fbshipit-source-id: f68e219b910a7242f2e72bb4d734c3e84f46eec5