// storage_view.h // // Copyright (c) 2023-2024 Junpei Kawamoto // // This software is released under the MIT License. // // http://opensource.org/licenses/mit-license.php #pragma once #include #include #include #include #include "rust/cxx.h" using ctranslate2::Device; using ctranslate2::StorageView; inline std::unique_ptr storage_view( const rust::Slice shape, const rust::Slice init, const Device device ) { return std::make_unique( ctranslate2::Shape(shape.begin(), shape.end()), init.data(), device ); } inline rust::String to_string(const StorageView& storage) { std::ostringstream oss; oss << storage; return rust::String(oss.str()); }