blob: a0b55552ca0fb3e5b73b12345b6b6cc533f68e67 [file] [log] [blame]
/**
* Copyright (c) 2020 CEA LIST
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*/
package org.eclipse.papyrus.aiml.profile.AIML.Normalization_layers.impl;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
import org.eclipse.papyrus.aiml.profile.AIML.Normalization_layers.LayerNorm;
import org.eclipse.papyrus.aiml.profile.AIML.Normalization_layers.Normalization_layersPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Layer Norm</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.papyrus.aiml.profile.AIML.Normalization_layers.impl.LayerNormImpl#getNormalized_shape <em>Normalized shape</em>}</li>
* <li>{@link org.eclipse.papyrus.aiml.profile.AIML.Normalization_layers.impl.LayerNormImpl#isElementwise_affine <em>Elementwise affine</em>}</li>
* </ul>
*
* @generated
*/
public class LayerNormImpl extends Normalization_layers_1Impl implements LayerNorm {
/**
* The cached value of the '{@link #getNormalized_shape() <em>Normalized shape</em>}' attribute list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getNormalized_shape()
* @generated
* @ordered
*/
protected EList<Integer> normalized_shape;
/**
* The default value of the '{@link #isElementwise_affine() <em>Elementwise affine</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isElementwise_affine()
* @generated
* @ordered
*/
protected static final boolean ELEMENTWISE_AFFINE_EDEFAULT = false;
/**
* The cached value of the '{@link #isElementwise_affine() <em>Elementwise affine</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isElementwise_affine()
* @generated
* @ordered
*/
protected boolean elementwise_affine = ELEMENTWISE_AFFINE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected LayerNormImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return Normalization_layersPackage.Literals.LAYER_NORM;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<Integer> getNormalized_shape() {
if (normalized_shape == null) {
normalized_shape = new EDataTypeUniqueEList<Integer>(Integer.class, this, Normalization_layersPackage.LAYER_NORM__NORMALIZED_SHAPE);
}
return normalized_shape;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean isElementwise_affine() {
return elementwise_affine;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setElementwise_affine(boolean newElementwise_affine) {
boolean oldElementwise_affine = elementwise_affine;
elementwise_affine = newElementwise_affine;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Normalization_layersPackage.LAYER_NORM__ELEMENTWISE_AFFINE, oldElementwise_affine, elementwise_affine));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case Normalization_layersPackage.LAYER_NORM__NORMALIZED_SHAPE:
return getNormalized_shape();
case Normalization_layersPackage.LAYER_NORM__ELEMENTWISE_AFFINE:
return isElementwise_affine();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case Normalization_layersPackage.LAYER_NORM__NORMALIZED_SHAPE:
getNormalized_shape().clear();
getNormalized_shape().addAll((Collection<? extends Integer>)newValue);
return;
case Normalization_layersPackage.LAYER_NORM__ELEMENTWISE_AFFINE:
setElementwise_affine((Boolean)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case Normalization_layersPackage.LAYER_NORM__NORMALIZED_SHAPE:
getNormalized_shape().clear();
return;
case Normalization_layersPackage.LAYER_NORM__ELEMENTWISE_AFFINE:
setElementwise_affine(ELEMENTWISE_AFFINE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case Normalization_layersPackage.LAYER_NORM__NORMALIZED_SHAPE:
return normalized_shape != null && !normalized_shape.isEmpty();
case Normalization_layersPackage.LAYER_NORM__ELEMENTWISE_AFFINE:
return elementwise_affine != ELEMENTWISE_AFFINE_EDEFAULT;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (normalized_shape: "); //$NON-NLS-1$
result.append(normalized_shape);
result.append(", elementwise_affine: "); //$NON-NLS-1$
result.append(elementwise_affine);
result.append(')');
return result.toString();
}
} //LayerNormImpl