chromium/services/webnn/public/cpp/webnn_errors.h

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_WEBNN_PUBLIC_CPP_WEBNN_ERRORS_H_
#define SERVICES_WEBNN_PUBLIC_CPP_WEBNN_ERRORS_H_

#include <string>

#include "base/component_export.h"
#include "services/webnn/public/cpp/operand_descriptor.h"
#include "services/webnn/public/cpp/supported_data_types.h"

namespace webnn {

namespace ops {
inline constexpr char kArgMax[] =;
inline constexpr char kArgMin[] =;
inline constexpr char kBatchNormalization[] =;
inline constexpr char kClamp[] =;
inline constexpr char kConcat[] =;
inline constexpr char kElu[] =;
inline constexpr char kExpand[] =;
inline constexpr char kGather[] =;
inline constexpr char kGatherElements[] =;
inline constexpr char kGelu[] =;
inline constexpr char kGemm[] =;
inline constexpr char kGru[] =;
inline constexpr char kGruCell[] =;
inline constexpr char kHardSigmoid[] =;
inline constexpr char kHardSwish[] =;
inline constexpr char kInstanceNormalization[] =;
inline constexpr char kLayerNormalization[] =;
inline constexpr char kLeakyRelu[] =;
inline constexpr char kLinear[] =;
inline constexpr char kLstm[] =;
inline constexpr char kLstmCell[] =;
inline constexpr char kMatmul[] =;
inline constexpr char kPad[] =;
inline constexpr char kPrelu[] =;
inline constexpr char kRelu[] =;
inline constexpr char kResample2d[] =;
inline constexpr char kReshape[] =;
inline constexpr char kSigmoid[] =;
inline constexpr char kSlice[] =;
inline constexpr char kSoftmax[] =;
inline constexpr char kSoftplus[] =;
inline constexpr char kSoftsign[] =;
inline constexpr char kSplit[] =;
inline constexpr char kTanh[] =;
inline constexpr char kTranspose[] =;
inline constexpr char kTriangular[] =;
inline constexpr char kWhere[] =;

// conv2d ops.
inline constexpr char kConv2d[] =;
inline constexpr char kConvTranspose2d[] =;

// elementwise binary ops.
inline constexpr char kAdd[] =;
inline constexpr char kSub[] =;
inline constexpr char kMul[] =;
inline constexpr char kDiv[] =;
inline constexpr char kMax[] =;
inline constexpr char kMin[] =;
inline constexpr char kPow[] =;
inline constexpr char kEqual[] =;
inline constexpr char kGreater[] =;
inline constexpr char kGreaterOrEqual[] =;
inline constexpr char kLesser[] =;
inline constexpr char kLesserOrEqual[] =;

// elementwise unary ops.
inline constexpr char kAbs[] =;
inline constexpr char kCeil[] =;
inline constexpr char kCos[] =;
inline constexpr char kExp[] =;
inline constexpr char kFloor[] =;
inline constexpr char kLog[] =;
inline constexpr char kNeg[] =;
inline constexpr char kSign[] =;
inline constexpr char kSin[] =;
inline constexpr char kTan[] =;
inline constexpr char kLogicalNot[] =;
inline constexpr char kIdentity[] =;
inline constexpr char kSqrt[] =;
inline constexpr char kErf[] =;
inline constexpr char kReciprocal[] =;
inline constexpr char kCast[] =;

// pooling
inline constexpr char kAveragePool2d[] =;
inline constexpr char kL2Pool2d[] =;
inline constexpr char kMaxPool2d[] =;

// reduce ops.
inline constexpr char kReduceL1[] =;
inline constexpr char kReduceL2[] =;
inline constexpr char kReduceLogSum[] =;
inline constexpr char kReduceLogSumExp[] =;
inline constexpr char kReduceMax[] =;
inline constexpr char kReduceMean[] =;
inline constexpr char kReduceMin[] =;
inline constexpr char kReduceProduct[] =;
inline constexpr char kReduceSum[] =;
inline constexpr char kReduceSumSquare[] =;

}  // namespace ops

std::string COMPONENT_EXPORT(WEBNN_PUBLIC_CPP)
    DataTypeToString(OperandDataType type);
std::string COMPONENT_EXPORT(WEBNN_PUBLIC_CPP)
    NotSupportedArgumentTypeError(std::string_view argument_name,
                                  OperandDataType type,
                                  SupportedDataTypes supported_types);
std::string COMPONENT_EXPORT(WEBNN_PUBLIC_CPP)
    NotSupportedConstantTypeError(OperandDataType type,
                                  SupportedDataTypes supported_types);
std::string COMPONENT_EXPORT(WEBNN_PUBLIC_CPP)
    NotSupportedInputArgumentTypeError(OperandDataType type,
                                       SupportedDataTypes supported_types);
std::string COMPONENT_EXPORT(WEBNN_PUBLIC_CPP)
    NotSupportedInputTypeError(std::string_view input_name,
                               OperandDataType type,
                               SupportedDataTypes supported_types);
std::string COMPONENT_EXPORT(WEBNN_PUBLIC_CPP)
    NotSupportedOpOutputTypeError(OperandDataType type,
                                  SupportedDataTypes supported_types);
std::string COMPONENT_EXPORT(WEBNN_PUBLIC_CPP)
    NotSupportedOutputTypeError(std::string_view output_name,
                                OperandDataType type,
                                SupportedDataTypes supported_types);
std::string COMPONENT_EXPORT(WEBNN_PUBLIC_CPP)
    NotSupportedMLBufferTypeError(OperandDataType type,
                                  SupportedDataTypes supported_types);

std::string COMPONENT_EXPORT(WEBNN_PUBLIC_CPP)
    GetErrorLabelPrefix(std::string_view label);

}  // namespace webnn

#endif  // SERVICES_WEBNN_PUBLIC_CPP_WEBNN_ERRORS_H_