parent
7e659a0abc
commit
313afc9cce
@ -0,0 +1,51 @@
|
||||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License. */
|
||||
|
||||
#include "paddle/framework/op_kernel_type.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
|
||||
TEST(OpKernelType, ToString) {
|
||||
using OpKernelType = paddle::framework::OpKernelType;
|
||||
using DataType = paddle::framework::proto::DataType;
|
||||
using CPUPlace = paddle::platform::CPUPlace;
|
||||
using DataLayout = paddle::framework::DataLayout;
|
||||
using LibraryType = paddle::framework::LibraryType;
|
||||
|
||||
OpKernelType op_kernel_type(DataType::FP32, CPUPlace(), DataLayout::kNCHW,
|
||||
LibraryType::kCUDNN);
|
||||
|
||||
std::ostringstream stream;
|
||||
stream << op_kernel_type;
|
||||
ASSERT_EQ(
|
||||
stream.str(),
|
||||
"data_type[5]:data_layout[NCHW]:place[CPUPlace]:library_type[CUDNN]");
|
||||
}
|
||||
|
||||
TEST(OpKernelType, Hash) {
|
||||
using OpKernelType = paddle::framework::OpKernelType;
|
||||
using DataType = paddle::framework::proto::DataType;
|
||||
using CPUPlace = paddle::platform::CPUPlace;
|
||||
using GPUPlace = paddle::platform::GPUPlace;
|
||||
using DataLayout = paddle::framework::DataLayout;
|
||||
using LibraryType = paddle::framework::LibraryType;
|
||||
|
||||
OpKernelType op_kernel_type_1(DataType::FP32, CPUPlace(), DataLayout::kNCHW,
|
||||
LibraryType::kCUDNN);
|
||||
OpKernelType op_kernel_type_2(DataType::FP32, GPUPlace(0), DataLayout::kNCHW,
|
||||
LibraryType::kCUDNN);
|
||||
|
||||
OpKernelType::Hash hasher;
|
||||
ASSERT_NE(hasher(op_kernel_type_1), hasher(op_kernel_type_2));
|
||||
}
|
Loading…
Reference in new issue