Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove using namespace NeoML from public headers #1025

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions NeoML/include/NeoML/NeoML.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2023 ABBYY
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -149,6 +149,3 @@ limitations under the License.
#endif //!NEOML_COMPACT
#include <NeoML/ArchiveFile.h>

#ifndef NO_NEOML_NAMESPACE
using namespace NeoML;
#endif
4 changes: 3 additions & 1 deletion NeoML/test/src/LAMBSolverTest.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2021 ABBYY Production LLC
/* Copyright © 2021-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,8 @@ limitations under the License.

#include <TestFixture.h>

using namespace NeoML;

static NeoML::CFullyConnectedLayer* createSimpleNetwork( NeoML::CDnn& dnn )
{
// Single FC architecture
Expand Down
3 changes: 2 additions & 1 deletion NeoML/test/src/TestFixture.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2023 ABBYY
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@ limitations under the License.
#include <cmath>

namespace NeoMLTest {
using namespace NeoML;

CString GetTestDataFilePath( const CString& relativePath, const CString& fileName );

Expand Down
6 changes: 3 additions & 3 deletions NeoOnnx/include/NeoOnnx/NeoOnnxImport.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2020 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,7 +37,7 @@ struct NEOONNX_API CImportSettings {

// After the import the net is passed to NeoML::OptimizeDnn
// The settings used by OptimizeDnn
CDnnOptimizationSettings DnnOptimizationSettings{};
NeoML::CDnnOptimizationSettings DnnOptimizationSettings{};
};

// Information about ONNX optimizations
Expand Down Expand Up @@ -68,7 +68,7 @@ struct NEOONNX_API CImportedModelInfo {
// 1. ONNX-only optimizations. Mostly they just removed artifacts from ONNX generation. See OnnxOptimizationReport.
// 2. NeoML::OptimizeDnn. See OptimizationReport.
COnnxOptimizationReport OnnxOptimizationReport;
CDnnOptimizationReport OptimizationReport;
NeoML::CDnnOptimizationReport OptimizationReport;
};

// The load functions build CDnn based on ONNX in the following way:
Expand Down
4 changes: 3 additions & 1 deletion NeoOnnx/include/NeoOnnx/TensorLayout.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2020 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@ limitations under the License.
#include <NeoML/NeoML.h>

namespace NeoOnnx {
using TBlobDim = NeoML::TBlobDim;

// Desribes how the tensor is represented in memory
// tensorLayout[i] is the blob dimension, where i'th onnx axis is located
Expand All @@ -43,6 +44,7 @@ class CTensorLayout: public CFastArray<TBlobDim, 8> {

inline CTensorLayout::CTensorLayout( int dimCount )
{
using namespace NeoML;
SetBufferSize( dimCount );
// Next dimensions are educated guesses
// If they'll match future layers then it will save one transform operation
Expand Down
6 changes: 4 additions & 2 deletions NeoOnnx/src/AttributeGetters.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2020 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,8 @@ limitations under the License.
#include "TensorUtils.h"

namespace NeoOnnx {
using TBlobType = NeoML::TBlobType;
using CBlobDesc = NeoML::CBlobDesc;

// This file contains getters for different types of onnx attributes

Expand Down Expand Up @@ -113,7 +115,7 @@ inline void GetAttributeValue<CPtr<CDataTensor>>( const onnx::AttributeProto& at
}
CPtr<CDnnBlob> resultBlob = CDnnBlob::CreateBlob( value->Data()->GetMathEngine(), resultDataType, desc );

if( resultDataType == CT_Float ) {
if( resultDataType == NeoML::CT_Float ) {
LoadBlobData<float>( attribute.t(), *resultBlob );
} else {
LoadBlobData<int>( attribute.t(), *resultBlob );
Expand Down
4 changes: 3 additions & 1 deletion NeoOnnx/src/GraphInput.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2020 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,8 @@ limitations under the License.
#include "TensorUtils.h"
#include "NeoOnnxCheck.h"

using namespace NeoML;

namespace NeoOnnx {

CGraphInput::CGraphInput( const onnx::ValueInfoProto& input ) :
Expand Down
2 changes: 1 addition & 1 deletion NeoOnnx/src/GraphInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CGraphInput {
// Adds corresponding source layer to the dnn and returns its output as a user tensor
// If layout is given, it will be used as a layout for this tensor
// If layout is not given then CTensorLayout::IOLayout( dimCount ) is used
CPtr<const CUserTensor> AddSourceLayer( CDnn& dnn, const CTensorLayout* layout ) const;
CPtr<const CUserTensor> AddSourceLayer( NeoML::CDnn& dnn, const CTensorLayout* layout ) const;

private:
// Input name
Expand Down
4 changes: 3 additions & 1 deletion NeoOnnx/src/Operators/ActivationOperator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2021 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,8 @@ limitations under the License.
#include "ActivationOperator.h"
#include "NeoOnnxCheck.h"

using namespace NeoML;

namespace NeoOnnx {

CActivationOperatorBase::CActivationOperatorBase( const onnx::NodeProto& onnxNode, int opsetVersion,
Expand Down
6 changes: 3 additions & 3 deletions NeoOnnx/src/Operators/ActivationOperator.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2021 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -23,15 +23,15 @@ namespace NeoOnnx {
class CActivationOperatorBase : public CLayerOperator {
public:
CActivationOperatorBase( const onnx::NodeProto& onnxNode, int opsetVersion,
TActivationFunction activation );
NeoML::TActivationFunction activation );

protected:
// CLayerOperator methods
void AddLayers( const CTensorArray& inputs, CDnn& dnn, CTensorArray& outputs ) const override;

private:
// Activation function which is applied to the input by this operator
const TActivationFunction activation;
const NeoML::TActivationFunction activation;
};

//---------------------------------------------------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion NeoOnnx/src/Operators/ConvOperator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2020 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,8 @@ limitations under the License.
#include "NeoOnnxCheck.h"
#include "TensorUtils.h"

using namespace NeoML;

namespace NeoOnnx {

// Gets kernel shape
Expand Down
3 changes: 2 additions & 1 deletion NeoOnnx/src/Operators/EltwiseOperator.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2020 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,7 @@ limitations under the License.
#include <NeoML/Dnn/Layers/Onnx/OnnxEltwiseLayer.h>

namespace NeoOnnx {
using COnnxEltwiseLayer = NeoML::COnnxEltwiseLayer;

// Base class for operators which perform eltwise operations
template<COnnxEltwiseLayer::TOperation Operation>
Expand Down
4 changes: 3 additions & 1 deletion NeoOnnx/src/Operators/GlobalPoolOperator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2023 ABBYY
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,8 @@ limitations under the License.

#include "onnx.pb.h"

using namespace NeoML;

namespace NeoOnnx {

// Gets the maximum number of inputs in the given opset version
Expand Down
4 changes: 3 additions & 1 deletion NeoOnnx/src/Operators/OneHotOperator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2022 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,8 @@ limitations under the License.

#include <NeoML/Dnn/Layers/Onnx/OnnxOneHotLayer.h>

using namespace NeoML;

namespace NeoOnnx {

COneHotOperator::COneHotOperator( const onnx::NodeProto& oneHot, int opsetVersion ) :
Expand Down
4 changes: 3 additions & 1 deletion NeoOnnx/src/Operators/PadOperator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2023 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,8 @@ limitations under the License.
#include "NeoOnnxCheck.h"
#include "TensorUtils.h"

using namespace NeoML;

namespace NeoOnnx {

CPadOperator::CPadOperator( const onnx::NodeProto& pad, int opsetVersion ) :
Expand Down
2 changes: 1 addition & 1 deletion NeoOnnx/src/Operators/PoolOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CPoolOperatorBase : public CLayerOperator {
// AddLayers implementation for the given padding value and pooling layer
// The derivatives should call this method from their AddLayers
void AddLayersImpl( const CTensorArray& inputs, float padValue,
CPoolingLayer& layer, CDnn& dnn, CTensorArray& outputs ) const;
NeoML::CPoolingLayer& layer, CDnn& dnn, CTensorArray& outputs ) const;

private:
// Padding mode
Expand Down
4 changes: 2 additions & 2 deletions NeoOnnx/src/Operators/ResizeOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class CResizeOperator : public CLayerOperator {
void AddLayers( const CTensorArray& input, CDnn& dnn, CTensorArray& outputs ) const override;

private:
TInterpolationCoords getInterpolationCoords() const;
TInterpolationRound getInterpolationRound() const;
NeoML::TInterpolationCoords getInterpolationCoords() const;
NeoML::TInterpolationRound getInterpolationRound() const;
};

} // namespace NeoOnnx
4 changes: 3 additions & 1 deletion NeoOnnx/src/Operators/SliceOperator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2020 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -26,6 +26,8 @@ limitations under the License.

#include <NeoML/Dnn/Layers/Onnx/OnnxSliceLayer.h>

using namespace NeoML;

namespace NeoOnnx {

CSliceOperator::CSliceOperator( const onnx::NodeProto& slice, int opsetVersion ) :
Expand Down
4 changes: 3 additions & 1 deletion NeoOnnx/src/Optimization/GELUOptimizer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2023 ABBYY
/* Copyright © 2023-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,8 @@ limitations under the License.
#include "GELUOptimizer.h"
#include <NeoML/Dnn/Layers/Onnx/OnnxEltwiseLayer.h>

using namespace NeoML;

namespace NeoOnnx {

namespace optimization {
Expand Down
6 changes: 3 additions & 3 deletions NeoOnnx/src/Optimization/Graph.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2023 ABBYY
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -23,9 +23,9 @@ namespace optimization {

// NeoOnnx::optimization aliases for NeoML::optimization
using CGraph = NeoML::optimization::CGraph;
template<typename TLayer = CBaseLayer>
template<typename TLayer = NeoML::CBaseLayer>
using CLayerInput = NeoML::optimization::CLayerInput<TLayer>;
template<typename TLayer = CBaseLayer>
template<typename TLayer = NeoML::CBaseLayer>
using CLayerOutput = NeoML::optimization::CLayerOutput<TLayer>;

} // namespace optimization
Expand Down
11 changes: 7 additions & 4 deletions NeoOnnx/src/Tensor.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2017-2020 ABBYY Production LLC
/* Copyright © 2017-2024 ABBYY

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,9 @@ limitations under the License.
#include <NeoOnnx/TensorLayout.h>

namespace NeoOnnx {
using IMathEngine = NeoML::IMathEngine;
using CBaseLayer = NeoML::CBaseLayer;
using CDnnBlob = NeoML::CDnnBlob;

// Tensor shape
typedef CFastArray<int, 8> CTensorShape;
Expand Down Expand Up @@ -95,7 +98,7 @@ inline bool CTensorBase::checkTensorLayout() const
// Check that every dimension is valid and used only once
int mask = 0;
for( int dimIndex = 0; dimIndex < layout.Size(); ++dimIndex ) {
if( layout[dimIndex] < BD_BatchLength || layout[dimIndex] > BD_Count
if( layout[dimIndex] < NeoML::BD_BatchLength || layout[dimIndex] > NeoML::BD_Count
|| ( mask & ( 1 << layout[dimIndex] ) ) != 0 )
{
return false;
Expand Down Expand Up @@ -188,7 +191,7 @@ class CDataTensor : public CTensorBase {

inline CDataTensor::CDataTensor( IMathEngine& mathEngine ) :
CTensorBase( CTensorLayout(), TTensorType::Data ),
data( CDnnBlob::CreateVector( mathEngine, CT_Float, 1 ) )
data( CDnnBlob::CreateVector( mathEngine, NeoML::CT_Float, 1 ) )
{
NeoPresume( checkTensorLayout() );
}
Expand All @@ -205,7 +208,7 @@ inline CDataTensor::CDataTensor( const CTensorLayout& layout, const CDnnBlob& _d
inline bool CDataTensor::checkTensorLayout() const
{
// Checking that shape, layout and CDnnBlob are matching
for( TBlobDim i = BD_BatchLength; i < BD_Count; ++i ) {
for( TBlobDim i = NeoML::BD_BatchLength; i < NeoML::BD_Count; ++i ) {
const int index = Layout().Find( i );
if( index == NotFound && data->DimSize( i ) != 1 ) {
return false;
Expand Down
Loading
Loading