mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Add scalar type info to tensor print (#20483)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/20483 ghimport-source-id: 31bfc51af1060e83492315b96884fc725a1eb84f Differential Revision: D15334010 Pulled By: li-roy fbshipit-source-id: 199b575855146a7336d57c165191a16e7e1b5785
This commit is contained in:
parent
abb3698976
commit
51e40ab832
|
|
@ -64,9 +64,16 @@ class CAFFE2_API DeprecatedTypeProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toString() const {
|
std::string toString() const {
|
||||||
std::stringstream ss;
|
std::string base_str;
|
||||||
ss << at::toString(backend()) << at::toString(scalarType()) << "Type";
|
if (backend_ == Backend::Undefined || scalar_type_ == ScalarType::Undefined) {
|
||||||
return ss.str();
|
base_str = "UndefinedType";
|
||||||
|
} else {
|
||||||
|
base_str = std::string(at::toString(backend_)) + at::toString(scalar_type_) + "Type";
|
||||||
|
}
|
||||||
|
if (is_variable_) {
|
||||||
|
return "Variable[" + base_str + "]";
|
||||||
|
}
|
||||||
|
return base_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeprecatedTypeProperties & toBackend(Backend b) const {
|
DeprecatedTypeProperties & toBackend(Backend b) const {
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ void Tensor::enforce_invariants() {
|
||||||
|
|
||||||
void Tensor::print() const {
|
void Tensor::print() const {
|
||||||
if (defined()) {
|
if (defined()) {
|
||||||
std::cerr << "[" << dispatch_type().toString() << " " << sizes() << "]" << std::endl;
|
std::cerr << "[" << type().toString() << " " << sizes() << "]" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "[UndefinedTensor]" << std::endl;
|
std::cerr << "[UndefinedTensor]" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * Tensor::toString() const {
|
std::string Tensor::toString() const {
|
||||||
return dispatch_type().toString();
|
return type().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace at
|
} // namespace at
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ class CAFFE2_API Tensor {
|
||||||
return impl_.weak_use_count();
|
return impl_.weak_use_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
IntArrayRef sizes() const {
|
IntArrayRef sizes() const {
|
||||||
return impl_->sizes();
|
return impl_->sizes();
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ class CAFFE2_API Tensor {
|
||||||
return impl_.weak_use_count();
|
return impl_.weak_use_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
IntArrayRef sizes() const {
|
IntArrayRef sizes() const {
|
||||||
return impl_->sizes();
|
return impl_->sizes();
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
0.9526
|
0.9526
|
||||||
0.9975
|
0.9975
|
||||||
0.9999
|
0.9999
|
||||||
[ Variable[CPUType]{4} ] 1 2 [1, 2] [1., 2.]
|
[ Variable[CPUDoubleType]{4} ] 1 2 [1, 2] [1., 2.]
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
1
|
1
|
||||||
[ Variable[CPUType]{} ] abcd 2 1.5
|
[ Variable[CPULongType]{} ] abcd 2 1.5
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user