oneAPI 1.3 暫定仕様書 Rev. 1 の解説 (43)

その他

この記事は、https://www.oneapi.io/spec/ で 2023年9月14日に公開された『oneAPI 1.3 Provisional Specification Rev. 1』 (HTMLPDF) をベースにしています。原文は2000 ページ近くあり、翻訳の時間とリソースも限られるため、全文翻訳ではなく、記事形式で区切った仕様とその解説を提供することにしました。


この回では、『oneAPI 1.3 Provisional Specification Rev. 1』の「oneDAL」の「Tables」の節を取り上げています。

テーブル

ここでは、テーブルの概念に関連するタイプについて説明します。

タイプ 説明
table テーブルの概念の共通実装。ほかのテーブルタイプの基本クラス。
table_metadata テーブルメタデータ (英語) 概念の実装。
data_layout テーブル内に連続するデータブロックを格納するために使用されるデータレイアウトの列挙。
feature_type データに対して利用可能な操作のセットを定義するため、oneDAL で使用される特徴タイプの列挙。

テーブルタイプの要件

テーブルの概念の実装には以下を行います。

  1. テーブルの概念と制限 (不変性など) の定義に従います。
  2. oneapi::dal::table クラスから派生します。クラスの動作は拡張できますが、制限することはできません。
  3. 参照カウントされます。
  4. 新しい oneapi::dal::table サブタイプは、一意の ID 番号 (実行時にタイプのオブジェクトを表す種別「kind」) を定義する必要があります。

次のリストは、テーブルの種別とコピー割り当て操作を説明するため、テーブル API の例を示しています。

using namespace onedal;

// homogen_table sub-type を作成
dal::homogen_table table1 = homogen_table::wrap(queue, data_ptr, row_count, column_count);

// table1 と table2 は同じデータを共有します (データはコピーされません)
dal::table table2 = table1;

// 空のテーブルを作成
dal::table table3;

std::cout << table1.get_kind()     == table2.get_kind() << std::endl; // true
std::cout << homogen_table::kind() == table2.get_kind() << std::endl; // true
std::cout << table2.get_kind()     == table3.get_kind() << std::endl; // false

// table3 を table2 に参照します
table3 = table2;
std::cout << table2.get_kind() == table3.get_kind() << std::endl; // true

テーブルタイプ

oneDAL は、特定のデータ形式のテーブルの概念を実装するクラスのセットを定義します。

テーブルタイプ 説明
homogen テーブル 連続した、同種のデータを含む密なテーブル。

プログラミング・インターフェイス

この節のすべてのタイプと関数は、oneapi::dal 名前空間で宣言され、oneapi/dal/table/common.hpp ヘッダーファイルをインクルードして使用できます。

テーブル

テーブル概念の基本実装。table タイプとすべてのサブタイプは、参照カウントされます。

  1. インスタンスは、すべてのプロパティー値とデータを保持するテーブル実装へのポインターを格納する必要があります。
  2. 参照カウントは、同じ実装を参照するテーブル・オブジェクトの数を示します。
  3. テーブルは、同じ実装を共有するテーブル・オブジェクトの数と等しくなるように、参照カウントをインクリメントしなければなりません。
  4. テーブルがスコープ外になると、参照カウントをデクリメントする必要があります。参照カウントがゼロである場合、テーブルは実装を解放します。
class table {
public:
    table();

    table(const table& other);

    table(table&& other);

    table& operator=(const table& other);

    table& operator=(table&& other);

    bool has_data() const noexcept;

    std::int64_t get_column_count() const;

    std::int64_t get_row_count() const;

    const table_metadata& get_metadata() const;

    std::int64_t get_kind() const;

    data_layout get_data_layout() const;
};

クラスについては、こちら (英語) を参照してください。

テーブルのメタデータ

テーブルのメタデータ概念の実装。テーブル内のデータの追加情報を保持します。table_metadata のオブジェクトは、参照カウントされます。

class table_metadata {
public:
    table_metadata();

    table_metadata(const array<data_type>& dtypes, const array<feature_type>& ftypes);

    std::int64_t get_feature_count() const;

    const feature_type& get_feature_type(std::int64_t feature_index) const;

    const data_type& get_data_type(std::int64_t feature_index) const;
};

クラスについては、こちら (英語) を参照してください。

データレイアウト

data layout 概念の実装。

enum class data_layout { unknown, row_major, column_major };

クラスについては、こちら (英語) を参照してください。

特徴タイプ

論理データタイプの実装。

enum class feature_type { nominal, ordinal, interval, ratio };

クラスについては、こちら (英語) を参照してください。

同種テーブル

クラス homogen_table は、以下が当てはまるテーブルタイプの実装です。

  • テーブル内のデータは密であり、1 つの連続したメモリーブロックとして格納されます。
  • すべての列は同じデータタイプです。

プログラミング・インターフェイス

この節のすべてのタイプと関数は、oneapi::dal 名前空間で宣言され、oneapi/dal/table/homogen.hpp ヘッダーファイルをインクルードして使用できます。

class homogen_table : public table {
public:
    static std::int64_t kind();

    template <typename Data>
    static homogen_table wrap(const sycl::queue& queue,
                              const Data* data_pointer,
                              std::int64_t row_count,
                              std::int64_t column_count,
                              const sycl::vector_class<sycl::event>& dependencies = {},
                              data_layout layout = data_layout::row_major);

public:
    homogen_table();

    template <typename Data, typename ConstDeleter>
    homogen_table(const sycl::queue& queue,
                  const Data* data_pointer,
                  std::int64_t row_count,
                  std::int64_t column_count,
                  ConstDeleter&& data_deleter,
                  const sycl::vector_class<sycl::event>& dependencies = {},
                  data_layout layout                                  = data_layout::row_major);

    template <typename Data>
    const Data* get_data() const {
        return reinterpret_cast<const Data*>(this->get_data());
    }

    const void* get_data() const;

    std::int64_t get_kind() const {
        return kind();
    }
};

クラス、コンストラクター、パブリックメソッドについては、こちら (英語) を参照してください。


法務上の注意書き

The content of this oneAPI Specification is licensed under the Creative Commons Attribution 4.0 International License (英語). Unless stated otherwise, the sample code examples in this document are released to you under the MIT license (英語).

This specification is a continuation of Intel’s decades-long history of working with standards groups and industry/academia initiatives such as The Khronos Group*, to create and define specifications in an open and fair process to achieve interoperability and interchangeability. oneAPI is intended to be an open specification and we encourage you to help us make it better. Your feedback is optional, but to enable Intel to incorporate any feedback you may provide to this specification, and to further upstream your feedback to other standards bodies, including The Khronos Group SYCL* specification, please submit your feedback under the terms and conditions below. Any contribution of your feedback to the oneAPI Specification does not prohibit you from also contributing your feedback directly to other standard bodies, including The Khronos Group under their respective submission policies.

By opening an issue, providing feedback, or otherwise contributing to the specification, you agree that Intel will be free to use, disclose, reproduce, modify, license, or otherwise distribute your feedback at its sole discretion without any obligations or restrictions of any kind, including without limitation, intellectual property rights or licensing obligations.

This document contains information on products, services and/or processes in development. All information provided here is subject to change without notice.

© Intel Corporation. Intel、インテル、Intel ロゴ、その他のインテルの名称やロゴは、Intel Corporation またはその子会社の商標です。

* その他の社名、製品名などは、一般に各社の表示、商標または登録商標です。

« パート 42        目次        パート 44 »
タイトルとURLをコピーしました