diff --git a/paddle/framework/tensor.h b/paddle/framework/tensor.h index 657d3e6628..9d05b87408 100644 --- a/paddle/framework/tensor.h +++ b/paddle/framework/tensor.h @@ -76,7 +76,7 @@ class Tensor { inline T* mutable_data(DDim dims, platform::Place place); /*! Size of a single element in data() */ - inline size_t element_size() { return holder_->element_size(); } + inline size_t element_size() const { return holder_->element_size(); } /*! Return the dimensions of the memory block. */ inline const DDim& dims() const; diff --git a/paddle/framework/tensor_test.cc b/paddle/framework/tensor_test.cc index da0a4d6363..7747cb34fc 100644 --- a/paddle/framework/tensor_test.cc +++ b/paddle/framework/tensor_test.cc @@ -36,7 +36,7 @@ TEST(Tensor, DataAssert) { } catch (paddle::platform::EnforceNotMet err) { caught = true; std::string msg = - "holder_ should not be null\nTenosr holds no memory. Call " + "holder_ should not be null\nTensor holds no memory. Call " "Tensor::mutable_data first."; const char* what = err.what(); for (size_t i = 0; i < msg.length(); ++i) { @@ -114,7 +114,7 @@ TEST(Tensor, ShareDataWith) { } catch (paddle::platform::EnforceNotMet err) { caught = true; std::string msg = - "holder_ should not be null\nTenosr holds no memory. Call " + "holder_ should not be null\nTensor holds no memory. Call " "Tensor::mutable_data first."; const char* what = err.what(); for (size_t i = 0; i < msg.length(); ++i) {