<commit_before>/* 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. */

#pragma once

#include <iostream>

#include "paddle/platform/variant.h"

namespace paddle {
namespace platform {

struct CPUPlace {
  // WORKAROUND: for some reason, omitting this constructor
  // causes errors with boost 1.59 and OSX
  CPUPlace() {}

  // needed for variant equality comparison
  inline bool operator==(const CPUPlace &) const { return true; }
  inline bool operator!=(const CPUPlace &) const { return false; }
};

struct MKLDNNPlace {
  MKLDNNPlace() {}

  // needed for variant equality comparison
  inline bool operator==(const MKLDNNPlace &) const { return true; }
  inline bool operator!=(const MKLDNNPlace &) const { return false; }
};

struct GPUPlace {
  GPUPlace() : GPUPlace(0) {}
  explicit GPUPlace(int d) : device(d) {}

  inline int GetDeviceId() const { return device; }
  // needed for variant equality comparison
  inline bool operator==(const GPUPlace &o) const { return device == o.device; }
  inline bool operator!=(const GPUPlace &o) const { return !(*this == o); }

  int device;
};

struct CudnnPlace : public GPUPlace {
  CudnnPlace() : GPUPlace() {}
  explicit CudnnPlace(int d) : GPUPlace(d) {}
};

struct IsGPUPlace : public boost::static_visitor<bool> {
  bool operator()(const CPUPlace &) const { return false; }
  bool operator()(const MKLDNNPlace &) const { return false; }
  bool operator()(const GPUPlace &gpu) const { return true; }
};

struct IsMKLDNNPlace : public boost::static_visitor<bool> {
  bool operator()(const MKLDNNPlace &) const { return true; }
  bool operator()(const CPUPlace &) const { return false; }
  bool operator()(const GPUPlace &) const { return false; }
};

// Define the max number of Place in bit length. i.e., the max number of places
// should be less equal than 2^(NUM_PLACE_TYPE_LIMIT_IN_BIT)
#define NUM_PLACE_TYPE_LIMIT_IN_BIT 4

typedef boost::variant<CudnnPlace, GPUPlace, CPUPlace> Place;
<commit_msg>fix conflict of Place<commit_after>/* 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. */

#pragma once

#include <iostream>

#include "paddle/platform/variant.h"

namespace paddle {
namespace platform {

struct CPUPlace {
  // WORKAROUND: for some reason, omitting this constructor
  // causes errors with boost 1.59 and OSX
  CPUPlace() {}

  // needed for variant equality comparison
  inline bool operator==(const CPUPlace &) const { return true; }
  inline bool operator!=(const CPUPlace &) const { return false; }
};

struct MKLDNNPlace {
  MKLDNNPlace() {}

  // needed for variant equality comparison
  inline bool operator==(const MKLDNNPlace &) const { return true; }
  inline bool operator!=(const MKLDNNPlace &) const { return false; }
};

struct GPUPlace {
  GPUPlace() : GPUPlace(0) {}
  explicit GPUPlace(int d) : device(d) {}

  inline int GetDeviceId() const { return device; }
  // needed for variant equality comparison
  inline bool operator==(const GPUPlace &o) const { return device == o.device; }
  inline bool operator!=(const GPUPlace &o) const { return !(*this == o); }

  int device;
};

struct CudnnPlace : public GPUPlace {
  CudnnPlace() : GPUPlace() {}
  explicit CudnnPlace(int d) : GPUPlace(d) {}
};

struct IsGPUPlace : public boost::static_visitor<bool> {
  bool operator()(const CPUPlace &) const { return false; }
  bool operator()(const MKLDNNPlace &) const { return false; }
  bool operator()(const GPUPlace &gpu) const { return true; }
};

struct IsMKLDNNPlace : public boost::static_visitor<bool> {
  bool operator()(const MKLDNNPlace &) const { return true; }
  bool operator()(const CPUPlace &) const { return false; }
  bool operator()(const GPUPlace &) const { return false; }
};

// Define the max number of Place in bit length. i.e., the max number of places
// should be less equal than 2^(NUM_PLACE_TYPE_LIMIT_IN_BIT)
#define NUM_PLACE_TYPE_LIMIT_IN_BIT 4

typedef boost::variant<CudnnPlace, GPUPlace, CPUPlace, MKLDNNPlace> Place;

{'fraction_non_alphanumeric': 0.10189431704885343, 'fraction_numerical': 0.0055832502492522435, 'mean_word_length': 4.411003236245954, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5413380', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1448, 'n_words': 560}