Fix getDims, copyFromRawData and fromRawData bug.2

This commit is contained in:
Krad
2023-04-21 14:29:08 +08:00
parent fdc0ecfb32
commit a09a748051
2 changed files with 5 additions and 7 deletions

View File

@@ -239,11 +239,7 @@ namespace Aurora {
{
return 3;
}
if(mInfo[1] > 1)
{
return 2;
}
return 1;
return 2;
}
double *Matrix::getData() const {
@@ -322,7 +318,7 @@ namespace Aurora {
Matrix Matrix::copyFromRawData(double *data, int rows, int cols, int slices, ValueType type) {
int colsize = cols>0?cols:1;
int slicesize = slicesize>0?slicesize:1;
int slicesize = slices>0?slices:1;
int size = rows*colsize*slicesize;
double *newBuffer = malloc(size, type);
cblas_dcopy(size*type,data,1,newBuffer,1);

View File

@@ -29,12 +29,14 @@ double fourDecimalRound(double src){
TEST_F(FunctionTester, MatrixCreate) {
printf("1");
double * dataA =Aurora::malloc(9);
double * dataB = new double[9];
double * dataC = new double[9];
double * dataD = new double[9];
//mkl matrix
{
printf("2");
Aurora::Matrix A = Aurora::Matrix::New(dataA, 3, 3);
EXPECT_EQ(dataA, A.getData());
EXPECT_EQ(9, A.getDataSize());
@@ -106,7 +108,7 @@ TEST_F(FunctionTester, MatrixCreate) {
Aurora::Matrix C = Aurora::Matrix::fromRawData(tempData, 3, 3,1);
EXPECT_EQ(dataD, C.getData());
EXPECT_EQ(9, C.getDataSize());
EXPECT_EQ(3, C.getDims());
EXPECT_EQ(2, C.getDims());
EXPECT_EQ(3, C.getDimSize(0));
EXPECT_EQ(3, C.getDimSize(1));
EXPECT_EQ(1, C.getDimSize(2));