Skip to content

Commit

Permalink
change test method
Browse files Browse the repository at this point in the history
add a preheat calculation
  • Loading branch information
Haosonn authored and IskXCr committed Dec 20, 2023
1 parent 177f81d commit 3d0c232
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion modules/dnn/src/vkcom/src/op_nary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ bool OpNary::binaryForward(std::vector<Tensor>& ins, std::vector<Tensor>& outs)
Ptr<Pipeline> pipeline = pipelineFactoryPtr->getPipeline(shader_name, destTypes);
Ptr<CommandBuffer> cmdBuffer = cmdPoolPtr->allocBuffer();
Ptr<Descriptor> desSet = pipeline->createSet();
group_x_ = group_y_ = group_z_ = 1;
group_x_ = group_y_ = group_z_ = 1;
VkCommandBuffer cmdBufferReal = cmdBuffer->get();

auto begin = std::chrono::high_resolution_clock::now();
Expand Down
13 changes: 8 additions & 5 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ void cal(Mat &input1, Mat &input2, Mat &output, dnn::Net& net) {
net.setInput(input1, "input1");
net.setInput(input2, "input2");

output = net.forward();

auto begin = std::chrono::high_resolution_clock::now();
CV_LOG_DEBUG(NULL, "start forwarding");

output = net.forward();

auto end = std::chrono::high_resolution_clock::now();
cout << "Time elapsed: " << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() << " ms\n";
}
Expand Down Expand Up @@ -100,9 +100,11 @@ int main() {
net.connect(0, 0, 1, 0);
net.connect(0, 1, 1, 1);

int matDimH = 16384, matDimW = 16384;
Mat input1 = Mat::ones(matDimH, matDimW, CV_32F);
Mat input2 = Mat::ones(matDimH, matDimW, CV_32F);
Mat input1, input2, output;

int matDimH = 16392, matDimW = 16392;
input1 = Mat::ones(matDimH, matDimW, CV_32F);
input2 = Mat::ones(matDimH, matDimW, CV_32F);

net.setPreferableBackend(dnn::DNN_BACKEND_VKCOM);
net.setPreferableTarget(dnn::DNN_TARGET_VULKAN);
Expand All @@ -118,6 +120,7 @@ int main() {
// input2 = Mat::ones(3, 1, CV_32F);
// input2.at<float>(0, 0) = 2;
// cal(input1, input2, output, net);
// printMat(output);

// input1 = Mat::ones(3, 1, CV_32F);
// input2 = Mat::ones(1, 3, CV_32F);
Expand Down

0 comments on commit 3d0c232

Please sign in to comment.