18static void MPI_RANK_OFSTREAM(
const std::string& file_name, std::stringstream &content )
20 std::stringstream
file;
21 int my_rank; MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
22 file<<file_name<<
"_"<<my_rank;
24 std::ofstream ofs(
file.str().c_str(), std::ofstream::app);
33template<
typename T1,
typename T2>
34static std::ostream &
operator<<( std::ostream & os,
const std::pair<T1,T2> &p )
36 os<<
"<"<<p.first<<
","<<p.second<<
">";
42static std::ostream &
operator<<( std::ostream & os,
const std::vector<T> &v )
53static std::ostream &
operator<<( std::ostream & os,
const std::valarray<T> &v )
63template<
typename T,
size_t N>
64static std::ostream &
operator<<( std::ostream & os,
const std::array<T,N> &v )
75static std::ostream &
operator<<( std::ostream & os,
const std::set<T> &v )
85template<
typename T1,
typename T2>
86static std::ostream &
operator<<( std::ostream & os,
const std::map<T1,T2> &v )
88 for(
const auto &i : v )
90 os<<
i.first<<std::endl<<
i.second<<std::endl;
95static double cal_time(
const timeval &t_begin )
98 gettimeofday( &t_end, NULL);
99 return (
double)(t_end.tv_sec-t_begin.tv_sec) + (
double)(t_end.tv_usec-t_begin.tv_usec)/1000000.0;
103static double cut_time( timeval &t )
105 const double time = cal_time(t);
106 gettimeofday( &t, NULL);
111static std::vector<double> get_memory(
const int N)
113 std::vector<double> m;
115 std::ifstream ifs(
"/proc/meminfo");
117 m.push_back(stoi(s)/1024);
118 for(
int i=1;
i<
N; ++
i)
121 m.push_back(stoi(s)/1024);
#define N
Definition exp.cpp:24
#define T
Definition exp.cpp:237
int4 i[880]
Definition sincos.cpp:28
std::ostream & operator<<(std::ostream &os, const Tensor &tensor)
Overloaded operator<< for the Tensor class.
Definition tensor.cpp:329
file(GLOB ATen_CORE_SRCS "*.cpp") set(ATen_CPU_SRCS $
Definition CMakeLists.txt:1