Viam C++ SDK current
Loading...
Searching...
No Matches
mlmodel.hpp
1// Copyright 2023 Viam Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <variant>
18#include <vector>
19
20#include <boost/mp11/algorithm.hpp>
21#include <boost/mp11/list.hpp>
22
23#include <viam/api/service/mlmodel/v1/mlmodel.grpc.pb.h>
24
25#include <viam/sdk/services/mlmodel.hpp>
26
27namespace viam {
28namespace sdk {
29namespace impl {
30namespace mlmodel {
31
32using tensor_storage_types = boost::mp11::mp_transform<std::vector, MLModelService::base_types>;
33
34using tensor_storage = std::vector<boost::mp11::mp_rename<tensor_storage_types, std::variant>>;
35
36void copy_sdk_tensor_to_api_tensor(const MLModelService::tensor_views& source,
37 ::viam::service::mlmodel::v1::FlatTensor* target);
38
39MLModelService::tensor_views make_sdk_tensor_from_api_tensor(
40 const ::viam::service::mlmodel::v1::FlatTensor& api_tensor, tensor_storage* storage = nullptr);
41
42} // namespace mlmodel
43} // namespace impl
44} // namespace sdk
45} // namespace viam