mirror of
				https://github.com/ml-explore/mlx.git
				synced 2025-10-31 16:21:27 +08:00 
			
		
		
		
	Remove duplicate defines of StreamOrDevice and is_big_endian (#892)
This commit is contained in:
		| @@ -26,16 +26,6 @@ constexpr uint8_t MAGIC[] = { | ||||
|     0x59, | ||||
| }; | ||||
|  | ||||
| inline bool is_big_endian_() { | ||||
|   union ByteOrder { | ||||
|     int32_t i; | ||||
|     uint8_t c[4]; | ||||
|   }; | ||||
|   ByteOrder b = {0x01234567}; | ||||
|  | ||||
|   return b.c[0] == 0x01; | ||||
| } | ||||
|  | ||||
| } // namespace | ||||
|  | ||||
| /** Save array to out stream in .npy format */ | ||||
| @@ -94,7 +84,7 @@ void save(std::shared_ptr<io::Writer> out_stream, array a) { | ||||
|     uint16_t v1_header_len = header.tellp(); | ||||
|     const char* len_bytes = reinterpret_cast<const char*>(&v1_header_len); | ||||
|  | ||||
|     if (!is_big_endian_()) { | ||||
|     if (!is_big_endian()) { | ||||
|       magic_ver_len.write(len_bytes, 2); | ||||
|     } else { | ||||
|       magic_ver_len.write(len_bytes + 1, 1); | ||||
| @@ -106,7 +96,7 @@ void save(std::shared_ptr<io::Writer> out_stream, array a) { | ||||
|     uint32_t v2_header_len = header.tellp(); | ||||
|     const char* len_bytes = reinterpret_cast<const char*>(&v2_header_len); | ||||
|  | ||||
|     if (!is_big_endian_()) { | ||||
|     if (!is_big_endian()) { | ||||
|       magic_ver_len.write(len_bytes, 4); | ||||
|     } else { | ||||
|       magic_ver_len.write(len_bytes + 3, 1); | ||||
| @@ -219,7 +209,7 @@ array load(std::shared_ptr<io::Reader> in_stream, StreamOrDevice s) { | ||||
|   // Build primitive | ||||
|  | ||||
|   size_t offset = 8 + header_len_size + header.length(); | ||||
|   bool swap_endianness = read_is_big_endian != is_big_endian_(); | ||||
|   bool swap_endianness = read_is_big_endian != is_big_endian(); | ||||
|  | ||||
|   if (col_contiguous) { | ||||
|     std::reverse(shape.begin(), shape.end()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Cheng
					Cheng