wangkuiyi/gotorch

TestTensorString failed on macOS

Closed this issue · 1 comments

I noticed the failure due to TravsiCI failed with #191. TravisCI is configured to run on macOS VM.

=== RUN   TestTensorString
    TestTensorString: tensor_test.go:84: 
        	Error Trace:	tensor_test.go:84
        	Error:      	Not equal: 
        	            	expected: " 1.0000  1.1000  1.2000\n 2.0000  3.0000  4.0000\n[ CPUFloatType{2,3} ]"
        	            	actual  : "   0.0141    2.0000  512.0001\n   0.0000    0.0000    0.0000\n[ CPUDoubleType{2,3} ]"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,3 +1,3 @@
        	            	- 1.0000  1.1000  1.2000
        	            	- 2.0000  3.0000  4.0000
        	            	-[ CPUFloatType{2,3} ]
        	            	+   0.0141    2.0000  512.0001
        	            	+   0.0000    0.0000    0.0000
        	            	+[ CPUDoubleType{2,3} ]
        	Test:       	TestTensorString

This is because I changed the type [2][3]float32 into [][]float32 before passing the variable to Tensor.FromBlob. The variable of Go array is like C array -- flattened array of elements; however, the memory layout of a slice of slices is a C array of reflect.SlideHeaders.