Apache Singa
A General Distributed Deep Learning Library
mkldnn_utils.h
1 /*********************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 ************************************************************/
21 #ifndef SINGA_UTILS_MKLDNN_UTILS_H_
22 #define SINGA_UTILS_MKLDNN_UTILS_H_
23 
24 #include <mkldnn.hpp>
25 
26 namespace singa {
27  /*
28  supported data type by mkldnn
29  mkldnn_f32 - 32-bit/single-precision floating point.
30  mkldnn_s32 - 32-bit signed integer.
31  mkldnn_s16 - 16-bit signed integer.
32  mkldnn_s8 - 8-bit signed integer.
33  mkldnn_u8 - 8-bit unsigned integer.
34  */
35  inline mkldnn::memory::data_type GetMKLDNNDataType(DataType dtype) {
36  mkldnn::memory::data_type ret = mkldnn::memory::data_type::f32;
37  switch (dtype) {
38  case kFloat32:
39  ret = mkldnn::memory::data_type::f32;
40  break;
41  case kDouble:
42  LOG(FATAL) << "The data type " << DataType_Name(dtype)
43  << " is not support by mkldnn";
44  break;
45  case kFloat16:
46  LOG(FATAL) << "The data type " << DataType_Name(dtype)
47  << " is not support by mkldnn";
48  break;
49  default:
50  LOG(FATAL) << "The data type " << DataType_Name(dtype)
51  << " is not support by mkldnn";
52  }
53  return ret;
54  }
55 }
56 #endif // SINGA_UTILS_MKLDNN_UTILS_H_
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: common.h:48