Skip to content

Commit

Permalink
print sample output
Browse files Browse the repository at this point in the history
  • Loading branch information
CongMa13 committed Dec 4, 2023
1 parent 9b4a479 commit 259d0ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
24 changes: 17 additions & 7 deletions samples/01_contraction/simple_bilinear_contraction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ int bilinearContractionSample()
/*******************
* Initialize data
*******************/
int initMethod = 0; // TODO read value from commandline
int initMethod = 1; // TODO read value from commandline
for(int64_t i = 0; i < elementsA; i++)
{
if(initMethod == 0)
Expand Down Expand Up @@ -284,14 +284,9 @@ int bilinearContractionSample()
0 /* stream */));

#if !NDEBUG
bool printElements = false;
bool printElements = 1;
bool storeElements = false;

if(printElements || storeElements)
{
CHECK_HIP_ERROR(hipMemcpy(C, C_d, sizeC, hipMemcpyDeviceToHost));
}

if(printElements)
{
if(elementsA < MAX_ELEMENTS_PRINT_COUNT)
Expand All @@ -314,6 +309,15 @@ int bilinearContractionSample()
hiptensorPrintArrayElements(std::cout, C, elementsC);
std::cout << std::endl;
}

CHECK_HIP_ERROR(hipMemcpy(C, C_d, sizeC, hipMemcpyDeviceToHost));

if(elementsC < MAX_ELEMENTS_PRINT_COUNT)
{
std::cout << "Tensor D elements:\n";
hiptensorPrintArrayElements(std::cout, C, elementsC);
std::cout << std::endl;
}
}

if(storeElements)
Expand All @@ -327,6 +331,12 @@ int bilinearContractionSample()
hiptensorPrintElementsToFile(tensorB, B, elementsB, ", ");
tensorB.close();

tensorC.open("tensor_C.txt");
hiptensorPrintElementsToFile(tensorC, C, elementsC, ", ");
tensorC.close();

CHECK_HIP_ERROR(hipMemcpy(C, C_d, sizeC, hipMemcpyDeviceToHost));

tensorC.open("tensor_C_scale_contraction_results.txt");
hiptensorPrintElementsToFile(tensorC, C, elementsC, ", ");
tensorC.close();
Expand Down
4 changes: 2 additions & 2 deletions samples/01_contraction/simple_scale_contraction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int scaleContractionSample()
/*******************
* Initialize data
*******************/
int initMethod = 0; // TODO read the value from command line
int initMethod = 1; // TODO read the value from command line
for(int64_t i = 0; i < elementsA; i++)
{
if(initMethod == 0)
Expand Down Expand Up @@ -274,7 +274,7 @@ int scaleContractionSample()
0 /* stream */));

#if !NDEBUG
bool printElements = false;
bool printElements = 1;
bool storeElements = false;

if(printElements || storeElements)
Expand Down

0 comments on commit 259d0ae

Please sign in to comment.